From 6122580a3120d654e74f2631f78b175bd8bfbb2a Mon Sep 17 00:00:00 2001 From: "Matthew D. Groves" Date: Wed, 15 Nov 2023 14:37:44 -0500 Subject: [PATCH] more debugging stuff --- .github/workflows/ci-container.yml | 2 +- .../Functional/FunctionalTestBase.cs | 2 -- .../Users/Handlers/GetProfileHandlerTests.cs | 2 +- .../Conduit.Web/Users/Services/JwtSecrets.cs | 20 +++++++++++++++++-- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-container.yml b/.github/workflows/ci-container.yml index 4b1ed247a8..d33359008c 100644 --- a/.github/workflows/ci-container.yml +++ b/.github/workflows/ci-container.yml @@ -23,7 +23,7 @@ jobs: Couchbase__ScanConsistency: ${{ secrets.COUCHBASE__SCANCONSISTENCY }} JwtSecret__Issuer: ${{ secrets.JWTSECRET__ISSUER }} JwtSecret__Audience: ${{ secrets.JWTSECRET__AUDIENCE }} - JwtSecret__SecurityKey: "thisishardcodedtryingtofigureouttheissue29mjL7uvnxE6BDqP5aT3bYRg" + JwtSecret__SecurityKey: ${{ secrets.JWTSECRET__SECURITYKEY }} services: couchbase: diff --git a/Conduit/Conduit.Tests/Functional/FunctionalTestBase.cs b/Conduit/Conduit.Tests/Functional/FunctionalTestBase.cs index 6dd020a0a0..58e4db0213 100644 --- a/Conduit/Conduit.Tests/Functional/FunctionalTestBase.cs +++ b/Conduit/Conduit.Tests/Functional/FunctionalTestBase.cs @@ -1,8 +1,6 @@ using Conduit.Web; using Conduit.Web.Users.Services; -using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc.Testing; -using Microsoft.Extensions.DependencyInjection; namespace Conduit.Tests.Functional; diff --git a/Conduit/Conduit.Tests/Unit/Users/Handlers/GetProfileHandlerTests.cs b/Conduit/Conduit.Tests/Unit/Users/Handlers/GetProfileHandlerTests.cs index e3de3c491f..c77e9e5c13 100644 --- a/Conduit/Conduit.Tests/Unit/Users/Handlers/GetProfileHandlerTests.cs +++ b/Conduit/Conduit.Tests/Unit/Users/Handlers/GetProfileHandlerTests.cs @@ -28,7 +28,7 @@ public void SetUp() { Audience = "doesntmatter-audience", Issuer = "doesntmatter-issuer", - SecurityKey = "doesntmatter-securityKey" + SecurityKey = "doesntmatter-securityKey-doesntmatter-securityKey-doesntmatter-securityKey-doesntmatter-securityKey" }; _handler = new GetProfileHandler(_userDataServiceMock.Object, new GetProfileRequestValidator(), diff --git a/Conduit/Conduit.Web/Users/Services/JwtSecrets.cs b/Conduit/Conduit.Web/Users/Services/JwtSecrets.cs index d6e84411ea..503b954e35 100644 --- a/Conduit/Conduit.Web/Users/Services/JwtSecrets.cs +++ b/Conduit/Conduit.Web/Users/Services/JwtSecrets.cs @@ -1,8 +1,24 @@ -namespace Conduit.Web.Users.Services; +using System.Text; + +namespace Conduit.Web.Users.Services; public class JwtSecrets { public string Issuer { get; set; } public string Audience { get; set; } - public string SecurityKey { get; set; } + + private string _securityKey; + + public string SecurityKey + { + get => _securityKey; + set + { + byte[] byteArray = Encoding.UTF8.GetBytes(value); + var numBits = byteArray.Length * 8; + if (numBits <= 256) + throw new ArgumentException($"SecurityKey must be greater than 256 bits. The security key '{value}' is only '{numBits}' bits."); + _securityKey = value; + } + } } \ No newline at end of file