From d222f27220639ef771191292acdc82db87126edd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Rua?= <140734849+joao4all@users.noreply.github.com> Date: Wed, 8 May 2024 14:34:12 +0100 Subject: [PATCH] Feat #597 [Add] a full trust checkbox on the login form to allow connecting to servers with self signed certificates (#599) --- .github/workflows/CodeQuality.yml | 3 + .github/workflows/codeql.yml | 3 + .../Components/IndexComponentTestFixture.cs | 5 +- .../AuthenticationServiceTestFixture.cs | 2 + COMET.Web.Common/COMET.Web.Common.csproj | 2 +- .../Components/IndexComponent.razor | 2 +- .../Components/IndexComponent.razor.cs | 82 +++++++------ COMET.Web.Common/Components/Login.razor | 47 +++++--- COMET.Web.Common/Components/Login.razor.cs | 12 ++ .../Model/DTO/AuthenticationDto.cs | 5 + .../AuthenticationService.cs | 37 +++--- .../ViewModels/Components/ILoginViewModel.cs | 2 +- .../ViewModels/Components/LoginViewModel.cs | 51 ++++----- COMETwebapp.Tests/Pages/IndexTestFixture.cs | 108 ++++++++++++++++++ COMETwebapp/Pages/Index.razor | 6 +- COMETwebapp/Pages/Index.razor.cs | 61 +++++++--- COMETwebapp/Utilities/Constants.cs | 43 ++++--- COMETwebapp/appsettings.json | 1 + 18 files changed, 329 insertions(+), 143 deletions(-) create mode 100644 COMETwebapp.Tests/Pages/IndexTestFixture.cs diff --git a/.github/workflows/CodeQuality.yml b/.github/workflows/CodeQuality.yml index 54ddc5dc..9433b57e 100644 --- a/.github/workflows/CodeQuality.yml +++ b/.github/workflows/CodeQuality.yml @@ -30,6 +30,9 @@ jobs: with: dotnet-version: '8.0.x' + - name: add Github nuget feed + run: dotnet nuget add source https://nuget.pkg.github.com/STARIONGROUP/index.json -n StarionGithubFeed -u STARIONGROUP -p ${{ secrets.PACKAGE_TOKEN }} --store-password-in-clear-text + - name: add DevExpress nuget feed run: dotnet nuget add source https://nuget.devexpress.com/api -n DXFeed -u DevExpress -p ${{ secrets.DEVEXPRESS_NUGET_KEY }} --store-password-in-clear-text diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 9404ac57..d824f55c 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -39,6 +39,9 @@ jobs: with: languages: ${{ matrix.language }} + - name: add Github nuget feed + run: dotnet nuget add source https://nuget.pkg.github.com/STARIONGROUP/index.json -n StarionGithubFeed -u STARIONGROUP -p ${{ secrets.PACKAGE_TOKEN }} --store-password-in-clear-text + - name: add DevExpress nuget feed run: dotnet nuget add source https://nuget.devexpress.com/api -n DXFeed -u DevExpress -p ${{ secrets.DEVEXPRESS_NUGET_KEY }} --store-password-in-clear-text diff --git a/COMET.Web.Common.Tests/Components/IndexComponentTestFixture.cs b/COMET.Web.Common.Tests/Components/IndexComponentTestFixture.cs index 5e0d73a9..7f63da7b 100644 --- a/COMET.Web.Common.Tests/Components/IndexComponentTestFixture.cs +++ b/COMET.Web.Common.Tests/Components/IndexComponentTestFixture.cs @@ -220,7 +220,10 @@ public void VerifyIndexPageWithRedirectionNotAuthorized() var url = QueryHelpers.AddQueryString("ModelDashboard", QueryKeys.ServerKey, targetServer); var renderer = this.context.RenderComponent(parameters => - parameters.Add(p => p.Redirect, url)); + { + parameters.Add(p => p.Redirect, url); + parameters.Add(p => p.FullTrustCheckboxVisible, true); + }); var login = renderer.FindComponent(); Assert.That(login.Instance.ViewModel.AuthenticationDto.SourceAddress, Is.EqualTo(targetServer)); diff --git a/COMET.Web.Common.Tests/Services/SessionManagement/AuthenticationServiceTestFixture.cs b/COMET.Web.Common.Tests/Services/SessionManagement/AuthenticationServiceTestFixture.cs index 1a23fb28..1ac2374f 100644 --- a/COMET.Web.Common.Tests/Services/SessionManagement/AuthenticationServiceTestFixture.cs +++ b/COMET.Web.Common.Tests/Services/SessionManagement/AuthenticationServiceTestFixture.cs @@ -77,6 +77,8 @@ public async Task VerifyLogout() public async Task VerifyValidLogin() { this.sessionService.Setup(x => x.OpenSession(It.IsAny())).ReturnsAsync(Result.Ok); + + this.authenticationDto.FullTrust = true; var loginResult = await this.authenticationService.Login(this.authenticationDto); Assert.That(loginResult.IsSuccess, Is.EqualTo(true)); diff --git a/COMET.Web.Common/COMET.Web.Common.csproj b/COMET.Web.Common/COMET.Web.Common.csproj index 161d8d40..ba88917d 100644 --- a/COMET.Web.Common/COMET.Web.Common.csproj +++ b/COMET.Web.Common/COMET.Web.Common.csproj @@ -32,7 +32,7 @@ - + diff --git a/COMET.Web.Common/Components/IndexComponent.razor b/COMET.Web.Common/Components/IndexComponent.razor index 22f04eb7..9e5be980 100644 --- a/COMET.Web.Common/Components/IndexComponent.razor +++ b/COMET.Web.Common/Components/IndexComponent.razor @@ -70,7 +70,7 @@
Connect and Open a Model.
Connect
- +
diff --git a/COMET.Web.Common/Components/IndexComponent.razor.cs b/COMET.Web.Common/Components/IndexComponent.razor.cs index 84fb9511..88cf3901 100644 --- a/COMET.Web.Common/Components/IndexComponent.razor.cs +++ b/COMET.Web.Common/Components/IndexComponent.razor.cs @@ -1,25 +1,24 @@ // -------------------------------------------------------------------------------------------------------------------- // -// Copyright (c) 2023-2024 Starion Group S.A. +// Copyright (c) 2024 Starion Group S.A. // -// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, Nabil Abbar +// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua // -// This file is part of CDP4-COMET WEB Community Edition -// The CDP4-COMET WEB Community Edition is the Starion Web Application implementation of ECSS-E-TM-10-25 -// Annex A and Annex C. +// This file is part of COMET WEB Community Edition +// The COMET WEB Community Edition is the Starion Group Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C. // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// The COMET WEB Community Edition is free software; you can redistribute it and/or +// modify it under the terms of the GNU Affero General Public +// License as published by the Free Software Foundation; either +// version 3 of the License, or (at your option) any later version. // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// The COMET WEB Community Edition is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Affero General Public License for more details. // +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . // // -------------------------------------------------------------------------------------------------------------------- @@ -29,7 +28,6 @@ namespace COMET.Web.Common.Components using CDP4Common.SiteDirectoryData; using COMET.Web.Common.Extensions; - using COMET.Web.Common.Services.RegistrationService; using COMET.Web.Common.Utilities; using COMET.Web.Common.ViewModels.Components; @@ -72,6 +70,12 @@ public partial class IndexComponent [Parameter] public string Redirect { get; set; } + /// + /// The condition to check if the full trust checkbox should be visible or not + /// + [Parameter] + public bool FullTrustCheckboxVisible { get; set; } + /// /// The /// @@ -98,29 +102,31 @@ protected override void OnParametersSet() { base.OnParametersSet(); - if (!string.IsNullOrEmpty(this.Redirect)) + if (string.IsNullOrEmpty(this.Redirect)) + { + return; + } + + var options = this.Redirect.GetParametersFromUrl(); + + if (options.TryGetValue(QueryKeys.ServerKey, out var server)) + { + this.requestedServer = server; + } + + if (options.TryGetValue(QueryKeys.ModelKey, out var model)) + { + this.requestedModel = model.FromShortGuid(); + } + + if (options.TryGetValue(QueryKeys.DomainKey, out var domain)) + { + this.requestedDomainOfExpertise = domain.FromShortGuid(); + } + + if (options.TryGetValue(QueryKeys.IterationKey, out var iteration)) { - var options = this.Redirect.GetParametersFromUrl(); - - if (options.TryGetValue(QueryKeys.ServerKey, out var server)) - { - this.requestedServer = server; - } - - if (options.TryGetValue(QueryKeys.ModelKey, out var model)) - { - this.requestedModel = model.FromShortGuid(); - } - - if (options.TryGetValue(QueryKeys.DomainKey, out var domain)) - { - this.requestedDomainOfExpertise = domain.FromShortGuid(); - } - - if (options.TryGetValue(QueryKeys.IterationKey, out var iteration)) - { - this.requestedIteration = iteration.FromShortGuid(); - } + this.requestedIteration = iteration.FromShortGuid(); } } diff --git a/COMET.Web.Common/Components/Login.razor b/COMET.Web.Common/Components/Login.razor index 262d9fc5..04279a0b 100644 --- a/COMET.Web.Common/Components/Login.razor +++ b/COMET.Web.Common/Components/Login.razor @@ -23,9 +23,9 @@ @inherits DisposableComponent - + - @if (string.IsNullOrEmpty(this.ViewModel.serverConnectionService.ServerConfiguration.ServerAddress)) + @if (string.IsNullOrEmpty(this.ViewModel.ServerConnectionService.ServerConfiguration.ServerAddress)) { } @@ -46,7 +46,7 @@ NullText="Enter your username" BindValueMode="BindValueMode.OnInput" @onfocus="@(() => this.HandleFieldFocus("UserName"))" - @onblur="@(() => this.HandleFieldBlur("UserName"))" /> + @onblur="@(() => this.HandleFieldBlur("UserName"))"/> @@ -60,6 +60,17 @@ Password="true"/> + + @if (this.FullTrustCheckboxVisible) + { + + + + }
    @@ -72,23 +83,29 @@ @if (fieldFocusedStatus.Key == "SourceAddress" && !string.IsNullOrEmpty(editFormContext.GetValidationMessages(() => this.ViewModel.AuthenticationDto.SourceAddress).FirstOrDefault())) { -
  • +
  • + +
  • } @if (fieldFocusedStatus.Key == "UserName" && !string.IsNullOrEmpty(editFormContext.GetValidationMessages(() => this.ViewModel.AuthenticationDto.UserName).FirstOrDefault())) { -
  • +
  • + +
  • } @if (fieldFocusedStatus.Key == "Password" && !string.IsNullOrEmpty(editFormContext.GetValidationMessages(() => this.ViewModel.AuthenticationDto.Password).FirstOrDefault())) { -
  • +
  • + +
  • } }
- @if (this.ErrorMessages.Any()) - { + @if (this.ErrorMessages.Any()) + {
    @foreach (var errrorMessage in this.ErrorMessages) @@ -97,11 +114,11 @@ }
- } + } - +
\ No newline at end of file diff --git a/COMET.Web.Common/Components/Login.razor.cs b/COMET.Web.Common/Components/Login.razor.cs index 64cd812e..ce34ff5b 100644 --- a/COMET.Web.Common/Components/Login.razor.cs +++ b/COMET.Web.Common/Components/Login.razor.cs @@ -60,6 +60,18 @@ public partial class Login [Parameter] public string PasswordLabel { get; set; } = "Password:"; + /// + /// The label for the full trust checkbox field + /// + [Parameter] + public string FullTrustLabel { get; set; } = "FullTrust:"; + + /// + /// The condition to check if the full trust checkbox should be visible or not + /// + [Parameter] + public bool FullTrustCheckboxVisible { get; set; } = false; + /// /// The text of the login button /// diff --git a/COMET.Web.Common/Model/DTO/AuthenticationDto.cs b/COMET.Web.Common/Model/DTO/AuthenticationDto.cs index a2019664..487efba9 100644 --- a/COMET.Web.Common/Model/DTO/AuthenticationDto.cs +++ b/COMET.Web.Common/Model/DTO/AuthenticationDto.cs @@ -49,5 +49,10 @@ public class AuthenticationDto /// [Required] public string Password { get; set; } + + /// + /// Gets or sets the condition to check if full trust is active. This option allows connecting to servers with self signed certificates + /// + public bool FullTrust { get; set; } = false; } } diff --git a/COMET.Web.Common/Services/SessionManagement/AuthenticationService.cs b/COMET.Web.Common/Services/SessionManagement/AuthenticationService.cs index 11df039f..5ab7b1cd 100644 --- a/COMET.Web.Common/Services/SessionManagement/AuthenticationService.cs +++ b/COMET.Web.Common/Services/SessionManagement/AuthenticationService.cs @@ -1,30 +1,31 @@ // -------------------------------------------------------------------------------------------------------------------- // -// Copyright (c) 2023-2024 Starion Group S.A. +// Copyright (c) 2024 Starion Group S.A. // -// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, Nabil Abbar +// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua // -// This file is part of CDP4-COMET WEB Community Edition -// The CDP4-COMET WEB Community Edition is the Starion Web Application implementation of ECSS-E-TM-10-25 -// Annex A and Annex C. +// This file is part of COMET WEB Community Edition +// The COMET WEB Community Edition is the Starion Group Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C. // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// The COMET WEB Community Edition is free software; you can redistribute it and/or +// modify it under the terms of the GNU Affero General Public +// License as published by the Free Software Foundation; either +// version 3 of the License, or (at your option) any later version. // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// The COMET WEB Community Edition is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Affero General Public License for more details. // +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . // // -------------------------------------------------------------------------------------------------------------------- namespace COMET.Web.Common.Services.SessionManagement { + using System.Net; + using CDP4Dal; using CDP4Dal.DAL; @@ -36,8 +37,6 @@ namespace COMET.Web.Common.Services.SessionManagement using Microsoft.AspNetCore.Components.Authorization; - using System.Net; - /// /// The purpose of the is to authenticate against /// a E-TM-10-25 Annex C.2 data source @@ -76,7 +75,7 @@ public AuthenticationService(ISessionService sessionService, AuthenticationState /// The authentication information with data source, username and password /// /// - /// The of the request + /// The of the request /// public async Task Login(AuthenticationDto authenticationDto) { @@ -89,7 +88,7 @@ public async Task Login(AuthenticationDto authenticationDto) } var uri = new Uri(authenticationDto.SourceAddress); - var credentials = new Credentials(authenticationDto.UserName, authenticationDto.Password, uri); + var credentials = new Credentials(authenticationDto.UserName, authenticationDto.Password, uri, authenticationDto.FullTrust); result = await this.sessionService.OpenSession(credentials); if (result.IsSuccess) diff --git a/COMET.Web.Common/ViewModels/Components/ILoginViewModel.cs b/COMET.Web.Common/ViewModels/Components/ILoginViewModel.cs index e511256d..09293de2 100644 --- a/COMET.Web.Common/ViewModels/Components/ILoginViewModel.cs +++ b/COMET.Web.Common/ViewModels/Components/ILoginViewModel.cs @@ -38,7 +38,7 @@ public interface ILoginViewModel /// /// Gets the /// - IConfigurationService serverConnectionService { get; } + IConfigurationService ServerConnectionService { get; } /// /// Gets or sets the loading state diff --git a/COMET.Web.Common/ViewModels/Components/LoginViewModel.cs b/COMET.Web.Common/ViewModels/Components/LoginViewModel.cs index 8111d92e..498204b3 100644 --- a/COMET.Web.Common/ViewModels/Components/LoginViewModel.cs +++ b/COMET.Web.Common/ViewModels/Components/LoginViewModel.cs @@ -1,25 +1,24 @@ // -------------------------------------------------------------------------------------------------------------------- // -// Copyright (c) 2023-2024 Starion Group S.A. +// Copyright (c) 2024 Starion Group S.A. // -// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, Nabil Abbar +// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua // -// This file is part of CDP4-COMET WEB Community Edition -// The CDP4-COMET WEB Community Edition is the Starion Web Application implementation of ECSS-E-TM-10-25 -// Annex A and Annex C. +// This file is part of COMET WEB Community Edition +// The COMET WEB Community Edition is the Starion Group Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C. // -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at +// The COMET WEB Community Edition is free software; you can redistribute it and/or +// modify it under the terms of the GNU Affero General Public +// License as published by the Free Software Foundation; either +// version 3 of the License, or (at your option) any later version. // -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// The COMET WEB Community Edition is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Affero General Public License for more details. // +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . // // -------------------------------------------------------------------------------------------------------------------- @@ -44,31 +43,31 @@ public class LoginViewModel : ReactiveObject, ILoginViewModel private readonly IAuthenticationService authenticationService; /// - /// Gets the + /// Backing field for /// - public IConfigurationService serverConnectionService { get; } + private Result authenticationResult = new(); /// /// Backing field for /// private bool isLoading; - /// - /// Backing field for - /// - private Result authenticationResult = new(); - /// /// Initializes a new instance of the class. /// /// The - /// The + /// The public LoginViewModel(IAuthenticationService authenticationService, IConfigurationService serverConnectionService) { - this.serverConnectionService = serverConnectionService; + this.ServerConnectionService = serverConnectionService; this.authenticationService = authenticationService; } + /// + /// Gets the + /// + public IConfigurationService ServerConnectionService { get; } + /// /// Gets or sets the loading state /// @@ -100,9 +99,9 @@ public async Task ExecuteLogin() { this.IsLoading = true; - if(!string.IsNullOrEmpty(this.serverConnectionService.ServerConfiguration.ServerAddress)) + if (!string.IsNullOrEmpty(this.ServerConnectionService.ServerConfiguration.ServerAddress)) { - this.AuthenticationDto.SourceAddress = this.serverConnectionService.ServerConfiguration.ServerAddress; + this.AuthenticationDto.SourceAddress = this.ServerConnectionService.ServerConfiguration.ServerAddress; } this.AuthenticationResult = await this.authenticationService.Login(this.AuthenticationDto); diff --git a/COMETwebapp.Tests/Pages/IndexTestFixture.cs b/COMETwebapp.Tests/Pages/IndexTestFixture.cs new file mode 100644 index 00000000..06dc2338 --- /dev/null +++ b/COMETwebapp.Tests/Pages/IndexTestFixture.cs @@ -0,0 +1,108 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// Copyright (c) 2024 Starion Group S.A. +// +// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua +// +// This file is part of COMET WEB Community Edition +// The COMET WEB Community Edition is the Starion Group Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C. +// +// The COMET WEB Community Edition is free software; you can redistribute it and/or +// modify it under the terms of the GNU Affero General Public +// License as published by the Free Software Foundation; either +// version 3 of the License, or (at your option) any later version. +// +// The COMET WEB Community Edition is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace COMETwebapp.Tests.Pages +{ + using Bunit; + using Bunit.TestDoubles; + + using CDP4Common.EngineeringModelData; + + using COMET.Web.Common.Components; + using COMET.Web.Common.Model.Configuration; + using COMET.Web.Common.Model.DTO; + using COMET.Web.Common.Services.SessionManagement; + using COMET.Web.Common.Test.Helpers; + using COMET.Web.Common.ViewModels.Components; + + using COMETwebapp.Pages; + using COMETwebapp.Utilities; + + using DynamicData; + + using Microsoft.Extensions.Configuration; + using Microsoft.Extensions.DependencyInjection; + + using Moq; + + using NUnit.Framework; + + using Result = FluentResults.Result; + using TestContext = Bunit.TestContext; + + [TestFixture] + public class IndexTestFixture + { + private Mock viewModel; + private TestContext context; + private Mock sessionService; + private readonly bool fullTrustValue = true; + + [SetUp] + public void Setup() + { + this.context = new TestContext(); + this.context.AddTestAuthorization(); + this.context.ConfigureDevExpressBlazor(); + + this.sessionService = new Mock(); + this.sessionService.Setup(x => x.OpenIterations).Returns(new SourceList()); + + this.viewModel = new Mock(); + this.viewModel.Setup(x => x.SessionService).Returns(this.sessionService.Object); + + var configuration = new Mock(); + configuration.Setup(x => x.GetSection(Constants.FullTrustSelectionEnabledKey).Value).Returns(this.fullTrustValue.ToString()); + + var loginViewModel = new Mock(); + loginViewModel.Setup(x => x.ServerConnectionService.ServerConfiguration).Returns(new ServerConfiguration()); + loginViewModel.Setup(x => x.AuthenticationResult).Returns(new Result()); + loginViewModel.Setup(x => x.AuthenticationDto).Returns(new AuthenticationDto()); + + this.context.Services.AddSingleton(loginViewModel.Object); + this.context.Services.AddSingleton(this.viewModel.Object); + this.context.Services.AddSingleton(this.sessionService.Object); + this.context.Services.AddSingleton(configuration.Object); + } + + [TearDown] + public void TearDown() + { + this.context.CleanContext(); + this.context.Dispose(); + } + + [Test] + public void VerifyIndexPageNotAuthorized() + { + var renderer = this.context.RenderComponent(); + + Assert.Multiple(() => + { + Assert.That(() => renderer.FindComponent(), Throws.Nothing); + Assert.That(renderer.Instance.FullTrustCheckboxVisible, Is.EqualTo(this.fullTrustValue)); + }); + } + } +} diff --git a/COMETwebapp/Pages/Index.razor b/COMETwebapp/Pages/Index.razor index 199f9ea2..05daed52 100644 --- a/COMETwebapp/Pages/Index.razor +++ b/COMETwebapp/Pages/Index.razor @@ -1,7 +1,7 @@ - @page "/" - + diff --git a/COMETwebapp/Pages/Index.razor.cs b/COMETwebapp/Pages/Index.razor.cs index d6d80b07..20b90173 100644 --- a/COMETwebapp/Pages/Index.razor.cs +++ b/COMETwebapp/Pages/Index.razor.cs @@ -1,29 +1,31 @@ // -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) 2023-2024 Starion Group S.A. -// -// Authors: Justine Veirier d'aiguebonne, Sam Gerené, Alex Vorobiev, Alexander van Delft -// -// This file is part of CDP4-COMET WEB Community Edition -// The CDP4-COMET WEB Community Edition is the Starion Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C. -// -// The CDP4-COMET WEB Community Edition is free software; you can redistribute it and/or -// modify it under the terms of the GNU Affero General Public -// License as published by the Free Software Foundation; either -// version 3 of the License, or (at your option) any later version. -// -// The CDP4-COMET WEB Community Edition is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// +// Copyright (c) 2024 Starion Group S.A. +// +// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua +// +// This file is part of COMET WEB Community Edition +// The COMET WEB Community Edition is the Starion Group Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C. +// +// The COMET WEB Community Edition is free software; you can redistribute it and/or +// modify it under the terms of the GNU Affero General Public +// License as published by the Free Software Foundation; either +// version 3 of the License, or (at your option) any later version. +// +// The COMET WEB Community Edition is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Affero General Public License for more details. -// +// // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -// -// -------------------------------------------------------------------------------------------------------------------- +// +// -------------------------------------------------------------------------------------------------------------------- namespace COMETwebapp.Pages { + using COMETwebapp.Utilities; + using Microsoft.AspNetCore.Components; /// @@ -37,5 +39,26 @@ public partial class Index [Parameter] [SupplyParameterFromQuery] public string Redirect { get; set; } + + /// + /// Gets or sets the + /// + [Inject] + public IConfiguration Configuration { get; set; } + + /// + /// Gets the condition to check if the full trust checkbox should be visible + /// + public bool FullTrustCheckboxVisible { get; private set; } + + /// + /// Method invoked when the component is ready to start, having received its + /// initial parameters from its parent in the render tree. + /// + protected override void OnInitialized() + { + base.OnInitialized(); + this.FullTrustCheckboxVisible = bool.Parse(this.Configuration.GetSection(Constants.FullTrustSelectionEnabledKey).Value!); + } } } diff --git a/COMETwebapp/Utilities/Constants.cs b/COMETwebapp/Utilities/Constants.cs index 394c4ef7..e1b7cea6 100644 --- a/COMETwebapp/Utilities/Constants.cs +++ b/COMETwebapp/Utilities/Constants.cs @@ -1,26 +1,26 @@ // -------------------------------------------------------------------------------------------------------------------- -// -// Copyright (c) 2023-2024 Starion Group S.A. -// -// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua -// -// This file is part of CDP4-COMET WEB Community Edition -// The CDP4-COMET WEB Community Edition is the Starion Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C. -// -// The CDP4-COMET WEB Community Edition is free software; you can redistribute it and/or -// modify it under the terms of the GNU Affero General Public -// License as published by the Free Software Foundation; either -// version 3 of the License, or (at your option) any later version. -// -// The CDP4-COMET WEB Community Edition is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// +// Copyright (c) 2024 Starion Group S.A. +// +// Authors: Sam Gerené, Alex Vorobiev, Alexander van Delft, Jaime Bernar, Théate Antoine, João Rua +// +// This file is part of COMET WEB Community Edition +// The COMET WEB Community Edition is the Starion Group Web Application implementation of ECSS-E-TM-10-25 Annex A and Annex C. +// +// The COMET WEB Community Edition is free software; you can redistribute it and/or +// modify it under the terms of the GNU Affero General Public +// License as published by the Free Software Foundation; either +// version 3 of the License, or (at your option) any later version. +// +// The COMET WEB Community Edition is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Affero General Public License for more details. -// +// // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -// -// -------------------------------------------------------------------------------------------------------------------- +// +// -------------------------------------------------------------------------------------------------------------------- namespace COMETwebapp.Utilities { @@ -33,5 +33,10 @@ public static class Constants /// The name of the configuration key used to retrieve the max upload file size, in megabytes /// public const string MaxUploadFileSizeInMbConfigurationKey = "MaxUploadFileSizeInMb"; + + /// + /// The name of the configuration key used to retrieve the condition to verify if the full trust selection is enabled + /// + public const string FullTrustSelectionEnabledKey = "FullTrustSelectionEnabled"; } } diff --git a/COMETwebapp/appsettings.json b/COMETwebapp/appsettings.json index 28e33cb3..060057d0 100644 --- a/COMETwebapp/appsettings.json +++ b/COMETwebapp/appsettings.json @@ -2,6 +2,7 @@ "AllowedHosts": "*", "StringTablePath": "wwwroot/DefaultTextConfiguration.json", "MaxUploadFileSizeInMb": 500, + "FullTrustSelectionEnabled": true, "ServerConfiguration": { "ServerAddress": "", "BookInputConfiguration": {