diff --git a/src/Tgstation.Server.Api/Models/ChatChannel.cs b/src/Tgstation.Server.Api/Models/ChatChannel.cs
new file mode 100644
index 0000000000..737b41203d
--- /dev/null
+++ b/src/Tgstation.Server.Api/Models/ChatChannel.cs
@@ -0,0 +1,23 @@
+namespace Tgstation.Server.Api.Models
+{
+ ///
+ /// Indicates a chat channel
+ ///
+ public sealed class ChatChannel
+ {
+ ///
+ /// The column ID
+ ///
+ public long Id { get; set; }
+
+ ///
+ /// The IRC channel name
+ ///
+ public string IrcChannel { get; set; }
+
+ ///
+ /// The Discord channel ID
+ ///
+ public long DiscordChannelId { get; set; }
+ }
+}
diff --git a/src/Tgstation.Server.Api/Models/ChatSettings.cs b/src/Tgstation.Server.Api/Models/ChatSettings.cs
index a528c1d773..593e6c4a8c 100644
--- a/src/Tgstation.Server.Api/Models/ChatSettings.cs
+++ b/src/Tgstation.Server.Api/Models/ChatSettings.cs
@@ -1,4 +1,6 @@
using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
using Tgstation.Server.Api.Rights;
namespace Tgstation.Server.Api.Models
@@ -19,6 +21,7 @@ namespace Tgstation.Server.Api.Models
/// The IRC server name
///
[Permissions(ReadRight = ChatSettingsRights.SetIrcSettings, WriteRight = ChatSettingsRights.SetIrcSettings)]
+ [Required]
public string IrcHost { get; set; }
///
@@ -33,18 +36,6 @@ namespace Tgstation.Server.Api.Models
[Permissions(ReadRight = ChatSettingsRights.SetIrcSettings, WriteRight = ChatSettingsRights.SetIrcSettings)]
public string IrcNickServPassword { get; set; }
- ///
- /// Channels the IRC client should join/listen/announce in and allow admin commands
- ///
- [Permissions(WriteRight = ChatSettingsRights.SetIrcChannels)]
- public List IrcAdminChannels { get; set; }
-
- ///
- /// Channels the IRC client should join/listen/announce in
- ///
- [Permissions(WriteRight = ChatSettingsRights.SetIrcChannels)]
- public List IrcGeneralChannels { get; set; }
-
///
/// If the Discord bot is enabled
///
@@ -58,14 +49,15 @@ namespace Tgstation.Server.Api.Models
public string DiscordBotToken { get; set; }
///
- /// Channels the Discord bot should listen/announce in and allow admin commands
+ /// Channels the bot should listen/announce in and allow admin commands
///
[Permissions(WriteRight = ChatSettingsRights.SetDiscordChannels)]
- public List DiscordAdminChannels { get; set; }
+ public virtual List AdminChannels { get; set; }
+
///
/// Channels the Discord bot should listen/announce in
///
[Permissions(WriteRight = ChatSettingsRights.SetDiscordChannels)]
- public List DiscordGeneralChannels { get; set; }
+ public virtual List GeneralChannels { get; set; }
}
}
diff --git a/src/Tgstation.Server.Api/Models/CompileJob.cs b/src/Tgstation.Server.Api/Models/CompileJob.cs
index 1133d86e50..4f1592a25e 100644
--- a/src/Tgstation.Server.Api/Models/CompileJob.cs
+++ b/src/Tgstation.Server.Api/Models/CompileJob.cs
@@ -1,5 +1,7 @@
using System;
using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
namespace Tgstation.Server.Api.Models
{
public class CompileJob
@@ -39,17 +41,10 @@ namespace Tgstation.Server.Api.Models
/// Exit code of DM. If , the job was cancelled
///
public int? ExitCode { get; set; }
-
+
///
/// Git revision the compiler ran on. Not modifiable
///
- [Required]
public RevisionInformation RevisionInformation { get; set; }
-
- ///
- /// Git revision of the origin branch the compiler ran on. Not modifiable
- ///
- [Required]
- public string OriginRevision { get; set; }
}
}
diff --git a/src/Tgstation.Server.Api/Models/Configuration.cs b/src/Tgstation.Server.Api/Models/Configuration.cs
index 4b750c9e6a..16b57be176 100644
--- a/src/Tgstation.Server.Api/Models/Configuration.cs
+++ b/src/Tgstation.Server.Api/Models/Configuration.cs
@@ -30,9 +30,7 @@ namespace Tgstation.Server.Api.Models
///
/// The content of the file. Will be if is or during listing operations
///
-#pragma warning disable CA1819 // Properties should not return arrays
public byte[] Content { get; set; }
-#pragma warning restore CA1819 // Properties should not return arrays
///
/// The MD5 hash of the file when last read by the user. Will be if is . If this doesn't match during update actions, the write will be denied with error code 409
diff --git a/src/Tgstation.Server.Api/Models/Instance.cs b/src/Tgstation.Server.Api/Models/Instance.cs
index 717efc7505..c1f198d30a 100644
--- a/src/Tgstation.Server.Api/Models/Instance.cs
+++ b/src/Tgstation.Server.Api/Models/Instance.cs
@@ -26,6 +26,7 @@ namespace Tgstation.Server.Api.Models
/// The path to where the is located
///
[Permissions(WriteRight = InstanceManagerRights.Relocate)]
+ [Required]
public string Path { get; set; }
///
diff --git a/src/Tgstation.Server.Api/Models/InstanceUser.cs b/src/Tgstation.Server.Api/Models/InstanceUser.cs
index 0dd9c3ca9e..2173fc2681 100644
--- a/src/Tgstation.Server.Api/Models/InstanceUser.cs
+++ b/src/Tgstation.Server.Api/Models/InstanceUser.cs
@@ -6,14 +6,8 @@ namespace Tgstation.Server.Api.Models
/// Represents a s permissions in an
///
[Model(RightsType.InstanceUser, WriteRight = InstanceUserRights.WriteUsers, CanList = true, RequiresInstance = true)]
- public sealed class InstanceUser
+ public class InstanceUser
{
- ///
- /// See definition in
- ///
- [Permissions(DenyWrite = true)]
- public long Id { get; set; }
-
///
/// The of the
///
@@ -37,7 +31,7 @@ namespace Tgstation.Server.Api.Models
///
/// The of the
///
- public ChatSettingsRights ChatRights { get; set; }
+ public ChatSettingsRights ChatSettingsRights { get; set; }
///
/// The of the
diff --git a/src/Tgstation.Server.Api/Models/Internal/DreamDaemonSettings.cs b/src/Tgstation.Server.Api/Models/Internal/DreamDaemonSettings.cs
index cdedd60a93..6288508a43 100644
--- a/src/Tgstation.Server.Api/Models/Internal/DreamDaemonSettings.cs
+++ b/src/Tgstation.Server.Api/Models/Internal/DreamDaemonSettings.cs
@@ -15,49 +15,42 @@ namespace Tgstation.Server.Api.Models.Internal
/// If starts when it's starts
///
[Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SetAutoStart)]
- [Required]
- public bool? AutoStart { get; set; }
+ public bool AutoStart { get; set; }
///
/// If the BYOND web client can be used to connect to the game server
///
[Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SetWebClient)]
- [Required]
- public bool? AllowWebClient { get; set; }
+ public bool AllowWebClient { get; set; }
///
/// If the server is undergoing a soft reset. This may be automatically set by changes to other fields
///
[Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SoftRestart)]
- [Required]
- public bool? SoftRestart { get; set; }
+ public bool SoftRestart { get; set; }
///
/// If the server is undergoing a soft shutdown
///
[Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SoftShutdown)]
- [Required]
- public bool? SoftShutdown { get; set; }
+ public bool SoftShutdown { get; set; }
///
/// The level of
///
[Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SetSecurity)]
- [Required]
- public DreamDaemonSecurity? SecurityLevel { get; set; }
+ public DreamDaemonSecurity SecurityLevel { get; set; }
///
/// The first port uses. This should be the publically advertised port
///
[Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SetPorts)]
- [Required]
- public ushort? PrimaryPort { get; set; }
+ public ushort PrimaryPort { get; set; }
///
/// The second port uses
///
[Permissions(ReadRight = DreamDaemonRights.ReadMetadata, WriteRight = DreamDaemonRights.SetPorts)]
- [Required]
- public ushort? SecondaryPort { get; set; }
+ public ushort SecondaryPort { get; set; }
}
}
diff --git a/src/Tgstation.Server.Api/Models/Internal/Job.cs b/src/Tgstation.Server.Api/Models/Internal/Job.cs
index 387cfac884..26266a20c5 100644
--- a/src/Tgstation.Server.Api/Models/Internal/Job.cs
+++ b/src/Tgstation.Server.Api/Models/Internal/Job.cs
@@ -22,6 +22,7 @@ namespace Tgstation.Server.Api.Models.Internal
[Required]
public DateTimeOffset StartedAt { get; set; }
+ [Required]
public User StartedBy { get; set; }
///
diff --git a/src/Tgstation.Server.Api/Models/Internal/RepositorySettings.cs b/src/Tgstation.Server.Api/Models/Internal/RepositorySettings.cs
new file mode 100644
index 0000000000..426ad618d2
--- /dev/null
+++ b/src/Tgstation.Server.Api/Models/Internal/RepositorySettings.cs
@@ -0,0 +1,56 @@
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using Tgstation.Server.Api.Rights;
+
+namespace Tgstation.Server.Api.Models.Internal
+{
+ public class RepositorySettings
+ {
+ ///
+ /// The origin URL. If , the does not exist
+ ///
+ [Permissions(WriteRight = RepositoryRights.SetOrigin)]
+ public string Origin { get; set; }
+
+ [Permissions(DenyWrite = true)]
+ public RevisionInformation RevisionInformation { get; set; }
+
+ ///
+ /// The name of the committer
+ ///
+ [Permissions(WriteRight = RepositoryRights.ChangeCommitter)]
+ [Required]
+ public string CommitterName { get; set; }
+
+ ///
+ /// The e-mail of the committer
+ ///
+ [Permissions(WriteRight = RepositoryRights.ChangeCommitter)]
+ [Required]
+ public string CommitterEmail { get; set; }
+
+ ///
+ /// The username to access the git repository with
+ ///
+ [Permissions(ReadRight = RepositoryRights.ChangeCredentials, WriteRight = RepositoryRights.ChangeCredentials)]
+ public string AccessUser { get; set; }
+
+ ///
+ /// The token/password to access the git repository with
+ ///
+ [Permissions(ReadRight = RepositoryRights.ChangeCredentials, WriteRight = RepositoryRights.ChangeCredentials)]
+ public string AccessToken { get; set; }
+
+ ///
+ /// If commits created from testmerges are pushed to the remote
+ ///
+ [Permissions(WriteRight = RepositoryRights.ChangeTestMergeCommits)]
+ public bool PushTestMergeCommits { get; set; }
+
+ ///
+ /// How often the automatically updates in minutes
+ ///
+ [Permissions(WriteRight = RepositoryRights.ChangeAutoUpdate)]
+ public int? AutoUpdateInterval { get; set; }
+ }
+}
diff --git a/src/Tgstation.Server.Api/Models/Internal/ServerSettings.cs b/src/Tgstation.Server.Api/Models/Internal/ServerSettings.cs
index 7c30871cea..7aa96da12b 100644
--- a/src/Tgstation.Server.Api/Models/Internal/ServerSettings.cs
+++ b/src/Tgstation.Server.Api/Models/Internal/ServerSettings.cs
@@ -5,7 +5,7 @@ namespace Tgstation.Server.Api.Models.Internal
public class ServerSettings
{
///
- /// Use the specified Windows/UNIX authentication to authorize users. Setting this to enables full administrative anonymous access
+ /// Use the specified Windows/POSIX authentication group to authorize users. Changing this may enable or disable s depending on how they were configured. Setting this to changes the authentication mode to database.
///
[Permissions(ReadRight = AdministrationRights.ChangeAuthenticationGroup, WriteRight = AdministrationRights.ChangeAuthenticationGroup)]
public string SystemAuthenticationGroup { get; set; }
diff --git a/src/Tgstation.Server.Api/Models/Internal/Token.cs b/src/Tgstation.Server.Api/Models/Internal/Token.cs
new file mode 100644
index 0000000000..3b1cad7574
--- /dev/null
+++ b/src/Tgstation.Server.Api/Models/Internal/Token.cs
@@ -0,0 +1,47 @@
+using System;
+using System.ComponentModel.DataAnnotations;
+using Tgstation.Server.Api.Rights;
+
+namespace Tgstation.Server.Api.Models.Internal
+{
+ ///
+ /// Represents an access token for the server. Read action generates a new one. Update action expires all for user
+ ///
+ [Model(RightsType.Token, CanList = true)]
+ public class Token
+ {
+ ///
+ /// The id of the . Not modifiable
+ ///
+ public long Id { get; set; }
+
+ ///
+ /// The user agent that created the
+ ///
+ [Required]
+ public string ClientUserAgent { get; set; }
+
+ [Required, MinLength(4), MaxLength(16)]
+ public byte[] IssuedTo { get; set; }
+
+ [Required, MinLength(4), MaxLength(16)]
+ public byte[] LastUsedBy { get; set; }
+
+ ///
+ /// When the was originally issued
+ ///
+ [Required]
+ public DateTimeOffset IssuedAt { get; set; }
+
+ ///
+ /// When the was last used
+ ///
+ public DateTimeOffset LastUsedAt { get; set; }
+
+ ///
+ /// The token . Not modifiable, only appears once
+ ///
+ [Required]
+ public string Value { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/Tgstation.Server.Api/Models/Repository.cs b/src/Tgstation.Server.Api/Models/Repository.cs
index eca73cace8..81e796ef00 100644
--- a/src/Tgstation.Server.Api/Models/Repository.cs
+++ b/src/Tgstation.Server.Api/Models/Repository.cs
@@ -7,17 +7,8 @@ namespace Tgstation.Server.Api.Models
/// Represents a git repository
///
[Model(RightsType.Repository, ReadRight = RepositoryRights.Read, RequiresInstance = true)]
- public sealed class Repository
+ public sealed class Repository : Internal.RepositorySettings
{
- ///
- /// The origin URL. If , the does not exist
- ///
- [Permissions(WriteRight = RepositoryRights.SetOrigin)]
- public string Origin { get; set; }
-
- [Permissions(DenyWrite = true)]
- public RevisionInformation RevisionInformation { get; set; }
-
///
/// The commit HEAD points to
///
@@ -30,49 +21,7 @@ namespace Tgstation.Server.Api.Models
[Permissions(WriteRight = RepositoryRights.SetReference)]
public string Reference { get; set; }
- ///
- /// The name of the committer
- ///
- [Permissions(WriteRight = RepositoryRights.ChangeCommitter)]
- public string CommitterName { get; set; }
-
- ///
- /// The e-mail of the committer
- ///
- [Permissions(WriteRight = RepositoryRights.ChangeCommitter)]
- public string CommitterEmail { get; set; }
-
- ///
- /// List of s in the repository
- ///
- [Permissions(DenyWrite = true)]
- public List TestMerges { get; set; }
-
[Permissions(WriteRight = RepositoryRights.MergePullRequest)]
public List NewTestMerges { get; set; }
-
- ///
- /// The username to access the git repository with
- ///
- [Permissions(ReadRight = RepositoryRights.ChangeCredentials, WriteRight = RepositoryRights.ChangeCredentials)]
- public string AccessUser { get; set; }
-
- ///
- /// The token/password to access the git repository with
- ///
- [Permissions(ReadRight = RepositoryRights.ChangeCredentials, WriteRight = RepositoryRights.ChangeCredentials)]
- public string AccessToken { get; set; }
-
- ///
- /// If commits created from testmerges are pushed to the remote
- ///
- [Permissions(WriteRight = RepositoryRights.ChangeTestMergeCommits)]
- public bool PushTestMergeCommits { get; set; }
-
- ///
- /// How often the automatically updates in minutes
- ///
- [Permissions(WriteRight = RepositoryRights.ChangeAutoUpdate)]
- public int? AutoUpdateInterval { get; set; }
}
}
\ No newline at end of file
diff --git a/src/Tgstation.Server.Api/Models/RevisionInformation.cs b/src/Tgstation.Server.Api/Models/RevisionInformation.cs
index e3724896c6..ea7165b24b 100644
--- a/src/Tgstation.Server.Api/Models/RevisionInformation.cs
+++ b/src/Tgstation.Server.Api/Models/RevisionInformation.cs
@@ -1,16 +1,17 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
namespace Tgstation.Server.Api.Models
{
- public sealed class RevisionInformation
+ public class RevisionInformation
{
- [Key]
- string Revision { get; set; }
+ [Required, StringLength(40)]
+ public string Revision { get; set; }
- [Required]
- string OriginRevision { get; set; }
-
- List TestMerges { get; set; }
+ [Required, StringLength(40)]
+ public string OriginRevision { get; set; }
+
+ public List TestMerges { get; set; }
}
}
diff --git a/src/Tgstation.Server.Api/Models/TestMerge.cs b/src/Tgstation.Server.Api/Models/TestMerge.cs
index 93724a46fa..1cb64db9ea 100644
--- a/src/Tgstation.Server.Api/Models/TestMerge.cs
+++ b/src/Tgstation.Server.Api/Models/TestMerge.cs
@@ -7,14 +7,8 @@ namespace Tgstation.Server.Api.Models
{
public long Id { get; set; }
- [Required]
- RevisionInformation RevisionInformation { get; set; }
-
[Required]
public DateTimeOffset MergedAt { get; set; }
-
- [Required]
- public DateTimeOffset RemovedAt { get; set; }
public User MergedBy { get; set; }
diff --git a/src/Tgstation.Server.Api/Models/Token.cs b/src/Tgstation.Server.Api/Models/Token.cs
index dffa764376..b709bea3d8 100644
--- a/src/Tgstation.Server.Api/Models/Token.cs
+++ b/src/Tgstation.Server.Api/Models/Token.cs
@@ -1,48 +1,22 @@
-using System;
-using System.ComponentModel.DataAnnotations;
-using System.Net;
-using Tgstation.Server.Api.Rights;
+using System.Net;
namespace Tgstation.Server.Api.Models
{
- ///
- /// Represents an access token for the server. Read action generates a new one. Update action expires all for user
- ///
- [Model(RightsType.Token, CanList = true)]
- public sealed class Token
+ ///
+ public sealed class Token : Internal.Token
{
- ///
- /// The id of the . Not modifiable
- ///
- public long Id { get; }
+ ///
+ new public IPAddress IssuedTo
+ {
+ get => new IPAddress(base.IssuedTo);
+ set => base.IssuedTo = value.GetAddressBytes();
+ }
- ///
- /// The user agent that created the
- ///
- [Required]
- public string ClientUserAgent { get; set; }
-
- ///
- /// The the was originally issued to
- ///
- [Required]
- public IPAddress IssuedTo { get; set; }
-
- ///
- /// When the was originally issued
- ///
- [Required]
- public DateTimeOffset IssuedAt { get; set; }
-
- ///
- /// When the was last used
- ///
- public DateTimeOffset LastUsedAt { get; set; }
-
- ///
- /// The token . Not modifiable, only appears once
- ///
- [Required]
- public string Value { get; set; }
+ ///
+ new public IPAddress LastUsedBy
+ {
+ get => new IPAddress(base.LastUsedBy);
+ set => base.LastUsedBy = value.GetAddressBytes();
+ }
}
-}
\ No newline at end of file
+}
diff --git a/src/Tgstation.Server.Api/Models/User.cs b/src/Tgstation.Server.Api/Models/User.cs
index e53f42e419..70bd28bed1 100644
--- a/src/Tgstation.Server.Api/Models/User.cs
+++ b/src/Tgstation.Server.Api/Models/User.cs
@@ -1,4 +1,6 @@
-using Tgstation.Server.Api.Rights;
+using System;
+using System.ComponentModel.DataAnnotations;
+using Tgstation.Server.Api.Rights;
namespace Tgstation.Server.Api.Models
{
@@ -14,26 +16,36 @@ namespace Tgstation.Server.Api.Models
[Permissions(DenyWrite = true)]
public long Id { get; set; }
+ [Permissions(DenyWrite = true)]
+ [Required]
+ public DateTimeOffset CreatedAt { get; set; }
+
///
/// The SID/UID of the on Windows/POSIX respectively
///
[Permissions(DenyWrite = true)]
- public string SystemId { get; set; }
+ public string SystemIdentifier { get; set; }
+
+ [Permissions(DenyWrite = true)]
+ public bool Enabled { get; set; }
///
/// The name of the
///
- [Permissions(DenyWrite = true)]
+ [Permissions(WriteRight = AdministrationRights.EditUsers)]
+ [Required]
public string Name { get; set; }
///
/// The for the
///
+ [Permissions(WriteRight = AdministrationRights.EditUsers)]
public AdministrationRights AdministrationRights { get; set; }
///
/// The for the
///
+ [Permissions(WriteRight = AdministrationRights.EditUsers)]
public InstanceManagerRights InstanceManagerRights { get; set; }
}
}
\ No newline at end of file
diff --git a/src/Tgstation.Server.Api/Rights/AdministrationRights.cs b/src/Tgstation.Server.Api/Rights/AdministrationRights.cs
index 5a9a37aaf8..c27ae958c9 100644
--- a/src/Tgstation.Server.Api/Rights/AdministrationRights.cs
+++ b/src/Tgstation.Server.Api/Rights/AdministrationRights.cs
@@ -13,7 +13,7 @@ namespace Tgstation.Server.Api.Rights
///
None = 0,
///
- /// User can change
+ /// User can change
///
ChangeAuthenticationGroup = 1,
///
@@ -35,7 +35,6 @@ namespace Tgstation.Server.Api.Rights
///
/// User can change
///
- SetUpstreamRepository
-
+ SetUpstreamRepository = 32
}
}
diff --git a/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj b/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj
index 2e3f40a448..51641091d2 100644
--- a/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj
+++ b/src/Tgstation.Server.Api/Tgstation.Server.Api.csproj
@@ -10,12 +10,12 @@
true
bin\Release\netstandard2.0\Tgstation.Server.Api.xml
- 1701;1702;1705;CA2227
+ 1701;1702;1705;CA2227;CA1819
latest
- 1701;1702;1705;CA2227
+ 1701;1702;1705;CA2227;CA1819
diff --git a/src/Tgstation.Server.Host.Console/Properties/launchSettings.json b/src/Tgstation.Server.Host.Console/Properties/launchSettings.json
index df4509a62a..5991274947 100644
--- a/src/Tgstation.Server.Host.Console/Properties/launchSettings.json
+++ b/src/Tgstation.Server.Host.Console/Properties/launchSettings.json
@@ -10,6 +10,7 @@
"profiles": {
"Tgstation.Server.Host.Console": {
"commandName": "Project",
+ "workingDirectory": "bin\\Debug\\netcoreapp2.0",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
diff --git a/src/Tgstation.Server.Host/Core/Application.cs b/src/Tgstation.Server.Host/Core/Application.cs
index e568a1526f..2a8d4f6f78 100644
--- a/src/Tgstation.Server.Host/Core/Application.cs
+++ b/src/Tgstation.Server.Host/Core/Application.cs
@@ -6,6 +6,7 @@ using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Globalization;
+using Tgstation.Server.Host.Configuration;
using Tgstation.Server.Host.Models;
namespace Tgstation.Server.Host.Core
@@ -36,8 +37,8 @@ namespace Tgstation.Server.Host.Core
{
if (services == null)
throw new ArgumentNullException(nameof(services));
-
- services.Configure(configuration.GetSection("Database"));
+ var workingDir = Environment.CurrentDirectory;
+ services.Configure(configuration.GetSection("Database"));
services.AddMvc();
services.AddOptions();
@@ -58,7 +59,7 @@ namespace Tgstation.Server.Host.Core
throw new ArgumentNullException(nameof(applicationBuilder));
if (hostingEnvironment == null)
throw new ArgumentNullException(nameof(hostingEnvironment));
-
+
if (hostingEnvironment.IsDevelopment())
applicationBuilder.UseDeveloperExceptionPage();
@@ -77,9 +78,13 @@ namespace Tgstation.Server.Host.Core
SupportedUICultures = supportedCultures,
});
- applicationBuilder.UseAsyncInitialization((databaseContext, cancellationToken) => databaseContext.Initialize(cancellationToken));
+ applicationBuilder.UseAsyncInitialization(async (cancellationToken) =>
+ {
+ using (var scop = applicationBuilder.ApplicationServices.CreateScope())
+ await scop.ServiceProvider.GetRequiredService().Initialize(cancellationToken).ConfigureAwait(false);
+ });
- applicationBuilder.UseSystemAuthentication();
+ applicationBuilder.UseSystemAuthentication();
applicationBuilder.UseMvc();
}
diff --git a/src/Tgstation.Server.Host/Core/AuthenticationContext.cs b/src/Tgstation.Server.Host/Core/AuthenticationContext.cs
index aa8235f1b8..fe4c5f9b8d 100644
--- a/src/Tgstation.Server.Host/Core/AuthenticationContext.cs
+++ b/src/Tgstation.Server.Host/Core/AuthenticationContext.cs
@@ -99,7 +99,7 @@ namespace Tgstation.Server.Host.Core
public void Dispose() => SystemIdentity.Dispose();
///
- public Task User(CancellationToken cancellationToken)
+ public Task User(CancellationToken cancellationToken)
{
throw new NotImplementedException();
}
diff --git a/src/Tgstation.Server.Host/Core/IAuthenticationContext.cs b/src/Tgstation.Server.Host/Core/IAuthenticationContext.cs
index 1d2466bbaf..a198c93ceb 100644
--- a/src/Tgstation.Server.Host/Core/IAuthenticationContext.cs
+++ b/src/Tgstation.Server.Host/Core/IAuthenticationContext.cs
@@ -20,7 +20,7 @@ namespace Tgstation.Server.Host.Core
///
/// The for the operation
/// A resulting in the represented by the
- Task User(CancellationToken cancellationToken);
+ Task User(CancellationToken cancellationToken);
///
/// The represented by and a given
diff --git a/src/Tgstation.Server.Host/Models/ChatSettings.cs b/src/Tgstation.Server.Host/Models/ChatSettings.cs
index 4c7ed23a76..0b798988c0 100644
--- a/src/Tgstation.Server.Host/Models/ChatSettings.cs
+++ b/src/Tgstation.Server.Host/Models/ChatSettings.cs
@@ -1,4 +1,6 @@
-using System.ComponentModel.DataAnnotations;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using Tgstation.Server.Api.Models;
namespace Tgstation.Server.Host.Models
{
diff --git a/src/Tgstation.Server.Host/Models/CompileJob.cs b/src/Tgstation.Server.Host/Models/CompileJob.cs
deleted file mode 100644
index 5d1b7b93cb..0000000000
--- a/src/Tgstation.Server.Host/Models/CompileJob.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System.ComponentModel.DataAnnotations;
-
-namespace Tgstation.Server.Host.Models
-{
- sealed class CompileJob : Api.Models.CompileJob
- {
- [Required]
- new User TriggeredBy { get; set; }
- }
-}
diff --git a/src/Tgstation.Server.Host/Models/DatabaseContext.cs b/src/Tgstation.Server.Host/Models/DatabaseContext.cs
index 6eaabd13b4..677733bc83 100644
--- a/src/Tgstation.Server.Host/Models/DatabaseContext.cs
+++ b/src/Tgstation.Server.Host/Models/DatabaseContext.cs
@@ -5,6 +5,7 @@ using Microsoft.Extensions.Options;
using System;
using System.Threading;
using System.Threading.Tasks;
+using Tgstation.Server.Api.Models;
using Tgstation.Server.Host.Configuration;
using ZNetCS.AspNetCore.Logging.EntityFrameworkCore;
@@ -12,16 +13,30 @@ namespace Tgstation.Server.Host.Models
{
sealed class DatabaseContext : DbContext, IDatabaseContext
{
+ ///
public DbSet ServerSettings { get; set; }
- public DbSet Users { get; set; }
+ ///
+ public DbSet Users { get; set; }
+ ///
public DbSet Instances { get; set; }
///
/// The for s
///
public DbSet Logs { get; set; }
+ public DbSet InstanceUsers { get; set; }
+ public DbSet ChatChannels { get; set; }
+ public DbSet ChatSettings { get; set; }
+ public DbSet DreamDaemonSettings { get; set; }
+ public DbSet DreamMakerSettings { get; set; }
+ public DbSet CompileJobs { get; set; }
+ public DbSet Jobs { get; set; }
+ public DbSet Tokens { get; set; }
+ public DbSet TestMerges { get; set; }
+ public DbSet RevisionInformations { get; set; }
+ public DbSet RepositorySettings { get; set; }
///
/// The for the
@@ -39,11 +54,11 @@ namespace Tgstation.Server.Host.Models
///
/// Construct a
///
- /// The for the
+ /// The for the
/// The containing the value of
/// The value of
/// The value of
- public DatabaseContext(DbContextOptions options, IOptions databaseConfigurationOptions, ILoggerFactory loggerFactory, IHostingEnvironment hostingEnvironment) : base(options)
+ public DatabaseContext(DbContextOptions dbContextOptions, IOptions databaseConfigurationOptions, ILoggerFactory loggerFactory, IHostingEnvironment hostingEnvironment) : base(dbContextOptions)
{
databaseConfiguration = databaseConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(databaseConfigurationOptions));
this.loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
@@ -57,8 +72,9 @@ namespace Tgstation.Server.Host.Models
// build default model.
LogModelBuilderHelper.Build(modelBuilder.Entity());
- // real relation database can map table:
- modelBuilder.Entity().ToTable(nameof(Log));
+ modelBuilder.Entity().ToTable(nameof(Logs));
+
+ modelBuilder.Entity().HasIndex(x => x.Revision).IsUnique();
}
///
diff --git a/src/Tgstation.Server.Host/Models/DbCompileJob.cs b/src/Tgstation.Server.Host/Models/DbCompileJob.cs
new file mode 100644
index 0000000000..6392c06024
--- /dev/null
+++ b/src/Tgstation.Server.Host/Models/DbCompileJob.cs
@@ -0,0 +1,13 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace Tgstation.Server.Host.Models
+{
+ sealed class DbCompileJob : Api.Models.CompileJob
+ {
+ [Required]
+ new public DbUser TriggeredBy { get; set; }
+
+ [Required]
+ new public RevisionInformation RevisionInformation { get; set; }
+ }
+}
diff --git a/src/Tgstation.Server.Host/Models/DbUser.cs b/src/Tgstation.Server.Host/Models/DbUser.cs
new file mode 100644
index 0000000000..401ce517be
--- /dev/null
+++ b/src/Tgstation.Server.Host/Models/DbUser.cs
@@ -0,0 +1,25 @@
+using System.Collections.Generic;
+using Tgstation.Server.Api.Models.Internal;
+
+namespace Tgstation.Server.Host.Models
+{
+ ///
+ /// Represents a in the database
+ ///
+ sealed class DbUser : Api.Models.User
+ {
+ public string PasswordHash { get; set; }
+
+ public string PasswordSalt { get; set; }
+
+ ///
+ /// The s for the
+ ///
+ public List InstanceUsers { get; set; }
+
+ ///
+ /// The s for the
+ ///
+ public List Tokens { get; set; }
+ }
+}
diff --git a/src/Tgstation.Server.Host/Models/DreamDaemonSettings.cs b/src/Tgstation.Server.Host/Models/DreamDaemonSettings.cs
index 9daccbbde5..f5da5c1243 100644
--- a/src/Tgstation.Server.Host/Models/DreamDaemonSettings.cs
+++ b/src/Tgstation.Server.Host/Models/DreamDaemonSettings.cs
@@ -4,13 +4,17 @@ namespace Tgstation.Server.Host.Models
{
sealed class DreamDaemonSettings : Api.Models.Internal.DreamDaemonSettings
{
- long Id { get; set; }
-
- int? ProcessId { get; set; }
+ public long Id { get; set; }
- long InstanceId { get; set; }
+ public int? ProcessId { get; set; }
+
+ public long InstanceId { get; set; }
+
+ public string AccessToken { get; set; }
[Required]
- Instance Instance { get; set; }
+ public Instance Instance { get; set; }
+
+ new public DbCompileJob CompileJob { get; set; }
}
}
diff --git a/src/Tgstation.Server.Host/Models/DreamMakerSettings.cs b/src/Tgstation.Server.Host/Models/DreamMakerSettings.cs
index eaddc22b8a..43b58c39e1 100644
--- a/src/Tgstation.Server.Host/Models/DreamMakerSettings.cs
+++ b/src/Tgstation.Server.Host/Models/DreamMakerSettings.cs
@@ -4,9 +4,13 @@ namespace Tgstation.Server.Host.Models
{
sealed class DreamMakerSettings : Api.Models.Internal.DreamMakerSettings
{
- long Id { get; set; }
- long InstanceId { get; set; }
+ public long Id { get; set; }
+
+ public long InstanceId { get; set; }
+
[Required]
- Instance Instance { get; set; }
+ public Instance Instance { get; set; }
+
+ public DbCompileJob CompileJob { get; set; }
}
}
diff --git a/src/Tgstation.Server.Host/Models/IDatabaseContext.cs b/src/Tgstation.Server.Host/Models/IDatabaseContext.cs
index 9330d3d175..647b50d83c 100644
--- a/src/Tgstation.Server.Host/Models/IDatabaseContext.cs
+++ b/src/Tgstation.Server.Host/Models/IDatabaseContext.cs
@@ -10,9 +10,9 @@ namespace Tgstation.Server.Host.Models
interface IDatabaseContext
{
///
- /// The s in the
+ /// The s in the
///
- DbSet Users { get; }
+ DbSet Users { get; }
///
/// The s in the
diff --git a/src/Tgstation.Server.Host/Models/Instance.cs b/src/Tgstation.Server.Host/Models/Instance.cs
index 6ebb7f8507..db1dfddde1 100644
--- a/src/Tgstation.Server.Host/Models/Instance.cs
+++ b/src/Tgstation.Server.Host/Models/Instance.cs
@@ -13,16 +13,19 @@ namespace Tgstation.Server.Host.Models
/// The for the
///
[Required]
- ChatSettings ChatSettings { get; set; }
+ public ChatSettings ChatSettings { get; set; }
///
/// The for the
///
[Required]
- DreamMakerSettings DreamMakerSettings { get; set; }
+ public DreamMakerSettings DreamMakerSettings { get; set; }
[Required]
- DreamDaemonSettings DreamDaemonSettings { get; set; }
+ public DreamDaemonSettings DreamDaemonSettings { get; set; }
+
+ [Required]
+ public RepositorySettings RepositorySettings { get; set; }
///
/// The s in the
@@ -35,9 +38,9 @@ namespace Tgstation.Server.Host.Models
public List TestMerges { get; set; }
///
- /// The s in the
+ /// The s in the
///
- public List CompileJobs { get; set; }
+ public List CompileJobs { get; set; }
///
/// The in the
diff --git a/src/Tgstation.Server.Host/Models/InstanceUser.cs b/src/Tgstation.Server.Host/Models/InstanceUser.cs
new file mode 100644
index 0000000000..7794b2d357
--- /dev/null
+++ b/src/Tgstation.Server.Host/Models/InstanceUser.cs
@@ -0,0 +1,7 @@
+namespace Tgstation.Server.Host.Models
+{
+ sealed class InstanceUser : Api.Models.InstanceUser
+ {
+ public long Id { get; set; }
+ }
+}
diff --git a/src/Tgstation.Server.Host/Models/Job.cs b/src/Tgstation.Server.Host/Models/Job.cs
index 2becf695ff..dd70b9bc04 100644
--- a/src/Tgstation.Server.Host/Models/Job.cs
+++ b/src/Tgstation.Server.Host/Models/Job.cs
@@ -5,8 +5,9 @@ namespace Tgstation.Server.Host.Models
sealed class Job : Api.Models.Internal.Job
{
[Required]
- new public User StartedBy { get; set; }
+ new public DbUser StartedBy { get; set; }
+ [Required]
Instance Instance { get; set; }
}
}
diff --git a/src/Tgstation.Server.Host/Models/RepositorySettings.cs b/src/Tgstation.Server.Host/Models/RepositorySettings.cs
new file mode 100644
index 0000000000..96412c401f
--- /dev/null
+++ b/src/Tgstation.Server.Host/Models/RepositorySettings.cs
@@ -0,0 +1,16 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace Tgstation.Server.Host.Models
+{
+ sealed class RepositorySettings : Api.Models.Internal.RepositorySettings
+ {
+ public long Id { get; set; }
+
+ public long InstanceId { get; set; }
+
+ [Required]
+ public Instance Instance { get; set; }
+
+ new public RevisionInformation RevisionInformation { get; set; }
+ }
+}
diff --git a/src/Tgstation.Server.Host/Models/RevisionInformation.cs b/src/Tgstation.Server.Host/Models/RevisionInformation.cs
new file mode 100644
index 0000000000..525a243d43
--- /dev/null
+++ b/src/Tgstation.Server.Host/Models/RevisionInformation.cs
@@ -0,0 +1,11 @@
+using System.Collections.Generic;
+
+namespace Tgstation.Server.Host.Models
+{
+ sealed class RevisionInformation : Api.Models.RevisionInformation
+ {
+ public long Id { get; set; }
+
+ new public List TestMerges { get; set; }
+ }
+}
diff --git a/src/Tgstation.Server.Host/Models/ServerSettings.cs b/src/Tgstation.Server.Host/Models/ServerSettings.cs
index 60576514ec..8a84475dad 100644
--- a/src/Tgstation.Server.Host/Models/ServerSettings.cs
+++ b/src/Tgstation.Server.Host/Models/ServerSettings.cs
@@ -1,7 +1,9 @@
-namespace Tgstation.Server.Host.Models
+using System.ComponentModel.DataAnnotations;
+
+namespace Tgstation.Server.Host.Models
{
sealed class ServerSettings : Api.Models.Internal.ServerSettings
{
- long Id { get; set; }
+ public long Id { get; set; }
}
}
diff --git a/src/Tgstation.Server.Host/Models/TestMerge.cs b/src/Tgstation.Server.Host/Models/TestMerge.cs
index d542473e5a..eac3df5d9f 100644
--- a/src/Tgstation.Server.Host/Models/TestMerge.cs
+++ b/src/Tgstation.Server.Host/Models/TestMerge.cs
@@ -8,6 +8,6 @@ namespace Tgstation.Server.Host.Models
sealed class TestMerge : Api.Models.TestMerge
{
[Required]
- new User MergedBy { get; set; }
+ new public DbUser MergedBy { get; set; }
}
}
diff --git a/src/Tgstation.Server.Host/Models/User.cs b/src/Tgstation.Server.Host/Models/User.cs
deleted file mode 100644
index 743ee5e8db..0000000000
--- a/src/Tgstation.Server.Host/Models/User.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using System.Collections.Generic;
-using Tgstation.Server.Api.Models;
-
-namespace Tgstation.Server.Host.Models
-{
- ///
- /// Represents a in the database
- ///
- sealed class User : Api.Models.User
- {
- ///
- /// The s for the
- ///
- List InstanceUsers { get; set; }
-
- ///
- /// The s for the
- ///
- List Tokens { get; set; }
- }
-}
diff --git a/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj b/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj
index bc0d5b6b3f..33b9c10d67 100644
--- a/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj
+++ b/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj
@@ -23,14 +23,20 @@
-
-
-
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
-
+
diff --git a/src/Tgstation.Server.Host/appsettings.Development.json b/src/Tgstation.Server.Host/appsettings.Development.json
index d3796e9ae8..1350bf6fde 100644
--- a/src/Tgstation.Server.Host/appsettings.Development.json
+++ b/src/Tgstation.Server.Host/appsettings.Development.json
@@ -19,6 +19,6 @@
},
"Database": {
"DatabaseType": "Sqlite",
- "ConnectionString": "Data Source=TestDB.sqlite3;Version=3;"
+ "ConnectionString": "Data Source=TestDB.sqlite3"
}
}