diff --git a/build/analyzers.ruleset b/build/analyzers.ruleset index d9ee572d87..15ba71dc89 100644 --- a/build/analyzers.ruleset +++ b/build/analyzers.ruleset @@ -668,6 +668,7 @@ + @@ -754,6 +755,7 @@ + diff --git a/src/Tgstation.Server.Host/GraphQL/Interfaces/IGateway.cs b/src/Tgstation.Server.Host/GraphQL/Interfaces/IGateway.cs index 56722119d2..1de582c06f 100644 --- a/src/Tgstation.Server.Host/GraphQL/Interfaces/IGateway.cs +++ b/src/Tgstation.Server.Host/GraphQL/Interfaces/IGateway.cs @@ -1,4 +1,6 @@ -using Tgstation.Server.Host.GraphQL.Types; +using System.Linq; + +using Tgstation.Server.Host.GraphQL.Types; namespace Tgstation.Server.Host.GraphQL.Interfaces { @@ -12,5 +14,11 @@ namespace Tgstation.Server.Host.GraphQL.Interfaces /// /// The for the . GatewayInformation Information(); + + /// + /// Queries all s in the . + /// + /// Queryable s. + IQueryable Instances(); } } diff --git a/src/Tgstation.Server.Host/GraphQL/Types/Instance.cs b/src/Tgstation.Server.Host/GraphQL/Types/Instance.cs index ea532baa9f..192a5b377b 100644 --- a/src/Tgstation.Server.Host/GraphQL/Types/Instance.cs +++ b/src/Tgstation.Server.Host/GraphQL/Types/Instance.cs @@ -3,8 +3,15 @@ using System.Linq; namespace Tgstation.Server.Host.GraphQL.Types { + /// + /// Represents a game server instance. + /// public sealed class Instance : Entity { + /// + /// Queries all s in the . + /// + /// Queryable s. public IQueryable QueryableInstancePermissionSets() => throw new NotImplementedException(); } diff --git a/src/Tgstation.Server.Host/GraphQL/Types/InstancePermissionSet.cs b/src/Tgstation.Server.Host/GraphQL/Types/InstancePermissionSet.cs index 4730c21aff..76bcabcac6 100644 --- a/src/Tgstation.Server.Host/GraphQL/Types/InstancePermissionSet.cs +++ b/src/Tgstation.Server.Host/GraphQL/Types/InstancePermissionSet.cs @@ -2,6 +2,9 @@ namespace Tgstation.Server.Host.GraphQL.Types { + /// + /// Represents a set of permissions for an . + /// public sealed class InstancePermissionSet { /// diff --git a/src/Tgstation.Server.Host/GraphQL/Types/LocalGateway.cs b/src/Tgstation.Server.Host/GraphQL/Types/LocalGateway.cs index 1428d2c2f2..8b6c329d94 100644 --- a/src/Tgstation.Server.Host/GraphQL/Types/LocalGateway.cs +++ b/src/Tgstation.Server.Host/GraphQL/Types/LocalGateway.cs @@ -13,6 +13,7 @@ namespace Tgstation.Server.Host.GraphQL.Types /// public GatewayInformation Information() => new(); + /// public IQueryable Instances() => throw new NotImplementedException(); } diff --git a/src/Tgstation.Server.Host/GraphQL/Types/RemoteGateway.cs b/src/Tgstation.Server.Host/GraphQL/Types/RemoteGateway.cs index 1a17b636e9..fcb9f088f4 100644 --- a/src/Tgstation.Server.Host/GraphQL/Types/RemoteGateway.cs +++ b/src/Tgstation.Server.Host/GraphQL/Types/RemoteGateway.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using Tgstation.Server.Host.GraphQL.Interfaces; @@ -12,5 +13,8 @@ namespace Tgstation.Server.Host.GraphQL.Types { /// public GatewayInformation Information() => throw new NotImplementedException(); + + /// + public IQueryable Instances() => throw new NotImplementedException(); } } diff --git a/src/Tgstation.Server.Host/Security/AuthenticationContextFactory.cs b/src/Tgstation.Server.Host/Security/AuthenticationContextFactory.cs index a8e0b59ff9..ba47b47a44 100644 --- a/src/Tgstation.Server.Host/Security/AuthenticationContextFactory.cs +++ b/src/Tgstation.Server.Host/Security/AuthenticationContextFactory.cs @@ -93,7 +93,9 @@ namespace Tgstation.Server.Host.Security public void Dispose() => currentAuthenticationContext.Dispose(); /// + #pragma warning disable CA1506 // TODO: Decomplexify public async Task ValidateToken(TokenValidatedContext tokenValidatedContext, CancellationToken cancellationToken) + #pragma warning restore CA1506 { ArgumentNullException.ThrowIfNull(tokenValidatedContext); @@ -190,8 +192,7 @@ namespace Tgstation.Server.Host.Security currentAuthenticationContext.Initialize( user, expires, - // signature is enough to uniquely identify the session as it is composite of all the inputs - jwt.EncodedSignature, + jwt.EncodedSignature, // signature is enough to uniquely identify the session as it is composite of all the inputs instancePermissionSet, systemIdentity); } diff --git a/tests/Tgstation.Server.Host.Tests/Security/TestAuthenticationContext.cs b/tests/Tgstation.Server.Host.Tests/Security/TestAuthenticationContext.cs index 1e0d7b7fa8..3ffee42382 100644 --- a/tests/Tgstation.Server.Host.Tests/Security/TestAuthenticationContext.cs +++ b/tests/Tgstation.Server.Host.Tests/Security/TestAuthenticationContext.cs @@ -13,32 +13,6 @@ namespace Tgstation.Server.Host.Security.Tests [TestClass] public sealed class TestAuthenticationContext { - [TestMethod] - public void TestConstruction() - { - Assert.ThrowsException(() => new AuthenticationContext().Initialize(null, null, null)); - var mockSystemIdentity = new Mock(); - - var user = new User() - { - PermissionSet = new PermissionSet() - }; - - var authContext = new AuthenticationContext(); - Assert.ThrowsException(() => new AuthenticationContext().Initialize(mockSystemIdentity.Object, null, null)); - - var instanceUser = new InstancePermissionSet(); - - Assert.ThrowsException(() => new AuthenticationContext().Initialize(null, null, instanceUser)); - Assert.ThrowsException(() => new AuthenticationContext().Initialize(mockSystemIdentity.Object, null, instanceUser)); - new AuthenticationContext().Initialize(mockSystemIdentity.Object, user, null); - new AuthenticationContext().Initialize(null, user, instanceUser); - new AuthenticationContext().Initialize(mockSystemIdentity.Object, user, instanceUser); - user.SystemIdentifier = "root"; - Assert.ThrowsException(() => new AuthenticationContext().Initialize(null, user, null)); - } - - [TestMethod] public void TestGetRightsGeneric() { @@ -48,7 +22,7 @@ namespace Tgstation.Server.Host.Security.Tests }; var instanceUser = new InstancePermissionSet(); var authContext = new AuthenticationContext(); - authContext.Initialize(null, user, instanceUser); + authContext.Initialize(user, DateTimeOffset.UtcNow, "asdf", instanceUser, null); user.PermissionSet.AdministrationRights = AdministrationRights.WriteUsers; instanceUser.EngineRights = EngineRights.InstallOfficialOrChangeActiveByondVersion | EngineRights.ReadActive;