-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Create Dialogporten Serviceowner client library #1513
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughThis pull request introduces a comprehensive update to the Dialogporten project, focusing on creating a new Web API client library. The changes include adding a new SDK with sample applications, integration tests, and extensive configuration for publishing and testing. The project now includes new workflow configurations for CI/CD, a NuGet package publishing process, and enhanced testing infrastructure. The modifications span multiple files across the project, introducing new services, configuration settings, and testing mechanisms for the Dialogporten API client. Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
src/Digdir.Library.Dialogporten.WebApiClient/Digdir.Library.Dialogporten.WebApiClient.csproj
Show resolved
Hide resolved
b859eb3
to
d33461f
Compare
# Conflicts: # src/Digdir.Domain.Dialogporten.WebApi/Digdir.Domain.Dialogporten.WebApi.csproj
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
♻️ Duplicate comments (6)
src/Digdir.Library.Dialogporten.WebApiClient/Digdir.Library.Dialogporten.WebApiClient.csproj (1)
15-15
:⚠️ Potential issueSecurity vulnerability in Maskinporten package.
Based on the past review comments, version 9.2.0 likely has the same moderate severity vulnerabilities as 9.2.1 in its JWT dependencies.
src/Digdir.Library.Dialogporten.WebApiClient.Sample/Program.cs (2)
31-33
:⚠️ Potential issueRemove hardcoded JSON Web Token (JWT)
Including a hardcoded JWT in the code poses a significant security risk. Tokens should be securely obtained at runtime and not stored in source code.
Apply this diff to replace the hardcoded token with a secure retrieval method:
-var token = - "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCIsImtpZCI6ImRldi1wcmltYXJ5LXNpZ25pbmcta2V5In0.eyJqdGkiOiIzNGZhMGViNS0xZGVmLTQxMDYtYWY4YS0xMjljYjNiNTliNDYiLCJjIjoidXJuOmFsdGlubjpwZXJzb246aWRlbnRpZmllci1ubzowODg5NTY5OTY4NCIsImwiOjMsInAiOiJ1cm46YWx0aW5uOnBlcnNvbjppZGVudGlmaWVyLW5vOjA4ODk1Njk5Njg0IiwicyI6InVybjphbHRpbm46cmVzb3VyY2U6c3VwZXItc2ltcGxlLXNlcnZpY2UiLCJpIjoiMDE5MzI1MzgtMzEzZC03NGI1LTg1ZWMtMWI5MGIxMjYzNWRjIiwiYSI6InJlYWQiLCJpc3MiOiJodHRwczovL2xvY2FsaG9zdDo3MjE0L2FwaS92MSIsImlhdCI6MTczMTU3ODk5OCwibmJmIjoxNzMxNTc4OTk4LCJleHAiOjE3MzE1Nzk1OTh9.fL-rpDsXqwOSVk5zMizLZRaFugaz2VfVNf0CjOxIhSdwrkAhh1UfRu5RcD2OK4ddnRrCuz8iKKJyadkek9UGAg"; +var token = await RetrieveTokenAsync(); // Implement a secure token retrieval methodEnsure that
RetrieveTokenAsync
securely obtains the token at runtime.🧰 Tools
🪛 Gitleaks (8.21.2)
32-32: Uncovered a JSON Web Token, which may lead to unauthorized access to web applications and sensitive user data.
(jwt)
59-59
:⚠️ Potential issueIncorrect assignment to
SystemLabel
propertyAssigning an enum value within array brackets is incorrect. The
SystemLabel
property expects a singleSystemLabel
value, not an array.Apply this diff to correct the assignment:
- SystemLabel = [DialogEndUserContextsEntities_SystemLabel.Default] + SystemLabel = DialogEndUserContextsEntities_SystemLabel.Default.github/workflows/ci-cd-staging.yml (1)
103-104
:⚠️ Potential issueFix secret name mismatch in workflow.
The workflow uses
NUGET_API_TEST_KEY
but the reusable workflow expectsNUGET_API_KEY
.secrets: - NUGET_API_KEY: ${{ secrets.NUGET_API_TEST_KEY }} + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}.github/workflows/ci-cd-main.yml (2)
123-123
:⚠️ Potential issueImprove robustness of project file path resolution.
The current implementation using
find
command embedded in thepath
parameter could be unreliable:
- Shell syntax might not work consistently in GitHub Actions.
- Pattern could match multiple files if there are test projects with similar names.
Consider using a dedicated step to find the project file:
publish-sdk-to-nuget: uses: ./.github/workflows/workflow-publish-nuget.yml needs: [ get-current-version, generate-git-short-sha, check-for-changes ] if: ${{ needs.check-for-changes.outputs.hasBackendChanges == 'true' || needs.check-for-changes.outputs.hasTestChanges == 'true' }} + run: | + PROJECT_PATH=$(find . -name "Digdir.Library.Dialogporten.WebApiClient.csproj" -not -path "*/test/*" -print -quit) + echo "PROJECT_PATH=$PROJECT_PATH" >> $GITHUB_ENV with: version: ${{ needs.get-current-version.outputs.version }}-rc.${{ needs.generate-git-short-sha.outputs.gitShortSha }} - path: $(find . -name '*Digdir.Library.Dialogporten.WebApiClient.csproj' -printf "%p" -quit) + path: ${{ env.PROJECT_PATH }}
124-125
:⚠️ Potential issueFix secret name mismatch in workflow.
The workflow uses
NUGET_API_TEST_KEY
but the reusable workflow expectsNUGET_API_KEY
.secrets: - NUGET_API_KEY: ${{ secrets.NUGET_API_TEST_KEY }} + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
🧹 Nitpick comments (9)
src/Digdir.Library.Dialogporten.WebApiClient/.refitter (2)
16-16
: Consider using RFC 3339 format with timezone offset.The current date format
yyyy-MM-ddTHH:mm:ssZ
assumes UTC (Z). Consider usingyyyy-MM-ddTHH:mm:sszzz
to support explicit timezone offsets, which is more flexible for international deployments.- "dateFormat": "yyyy-MM-ddTHH:mm:ssZ" + "dateFormat": "yyyy-MM-ddTHH:mm:sszzz"
1-18
: Add documentation comments.Consider adding a header comment block to document:
- The purpose of this configuration
- The dependency on Refitter version
- Any special considerations for developers
Add this comment block at the top of the file:
+// Configuration for Refitter code generation tool +// Generates Web API client for Dialogporten Serviceowner +// Note: Requires Refitter built from source: https://github.com/christianhelle/refitter + {src/Digdir.Library.Dialogporten.WebApiClient.Sample/Program.cs (1)
125-240
: Refactor duplicated code inCreateCommand()
andUpdateCommand()
methodsThe methods
CreateCommand()
andUpdateCommand()
contain duplicated code. Consider refactoring shared code into helper methods or using a builder pattern to improve maintainability and reduce duplication.Also applies to: 243-356
tests/Digdir.Library.Dialogporten.WebApiClient.Integration.Tests/WebApiClientTests.cs (1)
283-397
: Refactor duplicated code inCreateCommand()
andUpdateCommand()
methodsThe methods
CreateCommand()
andUpdateCommand()
have similar implementations. Refactoring common code into shared methods or utilizing a builder pattern can reduce code duplication and enhance maintainability.Also applies to: 398-553
.github/workflows/ci-cd-pull-request.yml (1)
21-21
: Remove trailing spaces.There are trailing spaces at the end of these lines.
Apply this diff:
- + - + - +Also applies to: 32-32, 43-43
🧰 Tools
🪛 yamllint (1.35.1)
[error] 21-21: trailing spaces
(trailing-spaces)
src/Digdir.Library.Dialogporten.WebApiClient/README.md (2)
4-4
: Fix bare URL formatting.Use proper Markdown link syntax for the URL.
Apply this diff:
-Refit-based client SDK Based on https://github.com/altinn/altinn-apiclient-maskinporten +Refit-based client SDK Based on [altinn-apiclient-maskinporten](https://github.com/altinn/altinn-apiclient-maskinporten)🧰 Tools
🪛 Markdownlint (0.37.0)
4-4: null
Bare URL used(MD034, no-bare-urls)
39-56
: Add example values in configuration.The configuration example should include sample values to help users understand the expected format.
Consider adding example values like this:
"DialogportenSettings": { - "Environment": "", + "Environment": "test", "Maskinporten": { - "ClientId": "", - "Scope": "", - "EncodedJwk": "" + "ClientId": "my-client-id", + "Scope": "altinn:dialog/write", + "EncodedJwk": "base64-encoded-jwk" } }, "Ed25519Keys": { "Primary": { - "Kid": "", - "PublicComponent": "" + "Kid": "primary-key-id", + "PublicComponent": "base64-encoded-public-key" }, "Secondary": { - "Kid": "", - "PublicComponent": "" + "Kid": "secondary-key-id", + "PublicComponent": "base64-encoded-public-key" } }.github/workflows/ci-cd-staging.yml (1)
105-105
: Remove trailing whitespace.Remove the trailing whitespace on this line.
- +🧰 Tools
🪛 yamllint (1.35.1)
[error] 105-105: trailing spaces
(trailing-spaces)
.github/workflows/ci-cd-main.yml (1)
126-126
: Remove trailing whitespace.Remove the trailing whitespace on this line.
- +🧰 Tools
🪛 yamllint (1.35.1)
[error] 126-126: trailing spaces
(trailing-spaces)
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (18)
.github/workflows/ci-cd-main.yml
(2 hunks).github/workflows/ci-cd-pull-request.yml
(3 hunks).github/workflows/ci-cd-staging.yml
(1 hunks).github/workflows/workflow-build-and-test.yml
(2 hunks).github/workflows/workflow-publish-nuget.yml
(1 hunks)Digdir.Domain.Dialogporten.sln
(3 hunks)src/Digdir.Domain.Dialogporten.WebApi/Digdir.Domain.Dialogporten.WebApi.csproj
(1 hunks)src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/EndUser/DialogActivities/Get/GetDialogActivityEndpointSummary.cs
(1 hunks)src/Digdir.Domain.Dialogporten.WebApi/Program.cs
(5 hunks)src/Digdir.Domain.Dialogporten.WebApi/nswag.json
(1 hunks)src/Digdir.Library.Dialogporten.WebApiClient.Sample/Program.cs
(1 hunks)src/Digdir.Library.Dialogporten.WebApiClient/.refitter
(1 hunks)src/Digdir.Library.Dialogporten.WebApiClient/Digdir.Library.Dialogporten.WebApiClient.csproj
(1 hunks)src/Digdir.Library.Dialogporten.WebApiClient/Extensions/ServiceCollectionExtensions.cs
(1 hunks)src/Digdir.Library.Dialogporten.WebApiClient/README.md
(1 hunks)src/Digdir.Library.Dialogporten.WebApiClient/Services/DialogTokenVerifier.cs
(1 hunks)tests/Digdir.Library.Dialogporten.WebApiClient.Integration.Tests/Digdir.Library.Dialogporten.WebApiClient.Integration.Tests.csproj
(1 hunks)tests/Digdir.Library.Dialogporten.WebApiClient.Integration.Tests/WebApiClientTests.cs
(1 hunks)
✅ Files skipped from review due to trivial changes (3)
- src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/EndUser/DialogActivities/Get/GetDialogActivityEndpointSummary.cs
- src/Digdir.Domain.Dialogporten.WebApi/nswag.json
- src/Digdir.Domain.Dialogporten.WebApi/Program.cs
🚧 Files skipped from review as they are similar to previous changes (3)
- Digdir.Domain.Dialogporten.sln
- tests/Digdir.Library.Dialogporten.WebApiClient.Integration.Tests/Digdir.Library.Dialogporten.WebApiClient.Integration.Tests.csproj
- src/Digdir.Library.Dialogporten.WebApiClient/Extensions/ServiceCollectionExtensions.cs
🧰 Additional context used
🪛 yamllint (1.35.1)
.github/workflows/ci-cd-main.yml
[error] 126-126: trailing spaces
(trailing-spaces)
.github/workflows/ci-cd-pull-request.yml
[error] 21-21: trailing spaces
(trailing-spaces)
[error] 32-32: trailing spaces
(trailing-spaces)
[error] 43-43: trailing spaces
(trailing-spaces)
.github/workflows/ci-cd-staging.yml
[error] 105-105: trailing spaces
(trailing-spaces)
.github/workflows/workflow-publish-nuget.yml
[error] 62-62: trailing spaces
(trailing-spaces)
🪛 Markdownlint (0.37.0)
src/Digdir.Library.Dialogporten.WebApiClient/README.md
4-4: null
Bare URL used
(MD034, no-bare-urls)
🪛 actionlint (1.7.4)
.github/workflows/workflow-publish-nuget.yml
61-61: shellcheck reported issue in this script: SC2035:info:1:19: Use ./glob or -- glob so names with dashes won't become options
(shellcheck)
🪛 Gitleaks (8.21.2)
src/Digdir.Library.Dialogporten.WebApiClient.Sample/Program.cs
32-32: Uncovered a JSON Web Token, which may lead to unauthorized access to web applications and sensitive user data.
(jwt)
🔇 Additional comments (12)
src/Digdir.Library.Dialogporten.WebApiClient/.refitter (2)
3-3
: Verify namespace alignment with project conventions.The namespace
Digdir.Library.Dialogporten.WebApiClient.Features.V1
should align with the project's namespace conventions.✅ Verification successful
Namespace follows project conventions ✅
The namespace
Digdir.Library.Dialogporten.WebApiClient.Features.V1
perfectly aligns with the project's established namespace hierarchy and versioning pattern.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check namespace conventions across the project # Search for other namespace declarations to verify consistency rg -t cs "namespace.*Digdir\.Library\.Dialogporten" --no-filename | sort | uniqLength of output: 456
8-10
: Verify completeness of included tags.The configuration only includes the "Serviceowner" tag. Verify if this covers all required API endpoints for the service owner client library.
✅ Verification successful
The "Serviceowner" tag inclusion is correct and complete
This is a service owner-specific client library, and the tag configuration correctly includes only the endpoints needed for this purpose. The separation from end-user and metadata endpoints is intentional and follows good API design practices.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Extract and compare available tags from swagger.json # Find all available tags in swagger.json fd swagger.json -x jq -r '.tags[].name' {} \;Length of output: 50
Script:
#!/bin/bash # Search for OpenAPI/Swagger specification files with various extensions echo "=== Looking for API specification files ===" fd -e json -e yaml -e yml | grep -i 'swagger\|openapi' echo -e "\n=== Searching for API endpoint attributes and tags in code ===" # Look for API controller attributes and tag usage rg -l "(\[ApiController\]|\[Route\]|\[Tags?\(|Serviceowner)" --type-add 'cs:*.cs' -tcs echo -e "\n=== Examining .refitter files ===" # Look at all .refitter files for context fd .refitter -x cat {}Length of output: 1009
Script:
#!/bin/bash echo "=== API Tags from swagger.verified.json ===" jq -r '.tags[] | "Tag: \(.name)\nDescription: \(.description)\n"' docs/schema/V1/swagger.verified.json echo -e "\n=== Paths grouped by tags ===" jq -r '.paths | to_entries[] | select(.value[].tags) | "\(.key): \(.value[].tags[])"' docs/schema/V1/swagger.verified.json | sortLength of output: 3209
src/Digdir.Library.Dialogporten.WebApiClient/Digdir.Library.Dialogporten.WebApiClient.csproj (2)
30-32
: LGTM! Good practice excluding test artifacts.Correctly excludes
.received.cs
files which are typically generated during snapshot testing.
16-17
: Verify .NET 9 compatibility.The project uses .NET 9 packages which are currently in preview. Consider using stable .NET 8 versions for production use:
- <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.0"/> - <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0"/> + <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.0"/> + <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0"/>.github/workflows/workflow-build-and-test.yml (2)
21-21
: Verify the 'test' environment configurationConfirm that the 'test' environment specified is correctly set up in GitHub and that the necessary protection rules and secrets are configured appropriately.
37-43
: Ensure secrets are not exposed in logs during testingWhen passing secrets through environment variables, make sure that these are not inadvertently logged during the test execution. Review the test configurations to prevent logging of sensitive information.
.github/workflows/workflow-publish-nuget.yml (2)
1-21
: LGTM! Well-structured workflow with clear inputs and secrets.The workflow is well-organized with appropriate input validation and defaults. The use of a default NuGet test source is a good practice.
61-62
:⚠️ Potential issueFix NuGet push command and remove trailing spaces.
The NuGet push command needs proper globbing and the file has trailing whitespace.
Apply this diff:
- run: dotnet nuget push *.nupkg --source "${{ inputs.source }}" --api-key ${{secrets.NUGET_API_KEY}} - + run: dotnet nuget push "./*.nupkg" --source "${{ inputs.source }}" --api-key "${{secrets.NUGET_API_KEY}}"Likely invalid or redundant comment.
🧰 Tools
🪛 actionlint (1.7.4)
61-61: shellcheck reported issue in this script: SC2035:info:1:19: Use ./glob or -- glob so names with dashes won't become options
(shellcheck)
🪛 yamllint (1.35.1)
[error] 62-62: trailing spaces
(trailing-spaces)
src/Digdir.Library.Dialogporten.WebApiClient/Services/DialogTokenVerifier.cs (1)
26-28
: 🛠️ Refactor suggestionAdd error handling for signature verification.
The
SignatureAlgorithm.Ed25519.Verify
method may throw exceptions if the inputs are invalid. Consider wrapping it in a try-catch block.Apply this diff:
- var signature = Base64Url.DecodeFromChars(parts[2]); - return SignatureAlgorithm.Ed25519.Verify(publicKey, Encoding.UTF8.GetBytes(parts[0] + '.' + parts[1]), signature); + try + { + var signature = Base64Url.DecodeFromChars(parts[2]); + return SignatureAlgorithm.Ed25519.Verify(publicKey, Encoding.UTF8.GetBytes(parts[0] + '.' + parts[1]), signature); + } + catch + { + return false; + }Likely invalid or redundant comment.
src/Digdir.Domain.Dialogporten.WebApi/Digdir.Domain.Dialogporten.WebApi.csproj (1)
16-20
: LGTM! Well-configured NSwag setup for OpenAPI generation.The NSwag packages and target are properly configured to generate OpenAPI specifications during Release builds.
Also applies to: 43-45
.github/workflows/ci-cd-staging.yml (1)
102-102
:⚠️ Potential issueImprove robustness of project file path resolution.
The current implementation using
find
command embedded in thepath
parameter could be unreliable:
- Shell syntax might not work consistently in GitHub Actions.
- Pattern could match multiple files if there are test projects with similar names.
Consider using a dedicated step to find the project file:
publish-sdk-to-nuget: uses: ./.github/workflows/workflow-publish-nuget.yml needs: [ get-current-version, check-for-changes ] if: ${{ needs.check-for-changes.outputs.hasBackendChanges == 'true' || needs.check-for-changes.outputs.hasTestChanges == 'true' }} + run: | + PROJECT_PATH=$(find . -name "Digdir.Library.Dialogporten.WebApiClient.csproj" -not -path "*/test/*" -print -quit) + echo "PROJECT_PATH=$PROJECT_PATH" >> $GITHUB_ENV with: version: ${{ needs.get-current-version.outputs.version }} - path: $(find . -name '*Digdir.Library.Dialogporten.WebApiClient.csproj' -printf "%p" -quit) + path: ${{ env.PROJECT_PATH }}Likely invalid or redundant comment.
.github/workflows/ci-cd-main.yml (1)
45-50
: LGTM! Well-structured secrets configuration.The secrets are properly organized and named according to their purpose.
src/Digdir.Library.Dialogporten.WebApiClient/Digdir.Library.Dialogporten.WebApiClient.csproj
Outdated
Show resolved
Hide resolved
src/Digdir.Library.Dialogporten.WebApiClient/Digdir.Library.Dialogporten.WebApiClient.csproj
Outdated
Show resolved
Hide resolved
src/Digdir.Library.Dialogporten.WebApiClient/Services/DialogTokenVerifier.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (4)
tests/Digdir.Domain.Dialogporten.WebApi.Integration.Tests/Features/V1/SwaggerSnapshotTests.cs (4)
5-5
: Scope the warning suppression to the specific method.The CS1998 warning suppression should be moved to the
FailIfSwaggerSnapshotDoesNotMatch
method to avoid suppressing the warning globally.-#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously namespace Digdir.Domain.Dialogporten.WebApi.Integration.Tests.Features.V1; public class SwaggerSnapshotTests : IClassFixture<WebApplicationFactory<Program>> { // ... + [SuppressMessage("ReSharper", "CS1998")] [Fact] public async Task FailIfSwaggerSnapshotDoesNotMatch()
29-29
: Avoid hardcoding file paths.The hardcoded path to
net9.0
could break if the target framework version changes. Consider making this configurable or deriving it from the project's target framework.- var newSwaggerPath = Path.Combine(rootPath!, "src/Digdir.Domain.Dialogporten.WebApi/bin/Release/net9.0/swagger.json"); + var targetFramework = typeof(Program).Assembly.GetCustomAttribute<TargetFrameworkAttribute>()?.FrameworkName ?? "net9.0"; + var newSwaggerPath = Path.Combine(rootPath!, "src/Digdir.Domain.Dialogporten.WebApi/bin/Release", targetFramework, "swagger.json");
47-47
: Improve the DEBUG mode error message.The error message could be more constructive by suggesting how to run the test in RELEASE mode.
- Assert.Fail("Swagger snapshot tests are not supported in DEBUG mode. Swagger is NOT generated in DEBUG mode, this is to keep build times low. therefore this test will always fail. Run in RELEASE mode to enable."); + Assert.Fail("Swagger snapshot tests require RELEASE mode.\n" + + "To run this test:\n" + + "1. Build the project in RELEASE mode: `dotnet build -c Release`\n" + + "2. Run the test in RELEASE mode: `dotnet test -c Release --filter SwaggerSnapshotTests`");
Line range hint
9-19
: Add XML documentation for the test class and method.Adding documentation would help other developers understand:
- The purpose of these snapshot tests
- When and why to run them in RELEASE mode
- The expected outcomes and how to handle failures
+/// <summary> +/// Validates that changes to the Swagger/OpenAPI specification are intentional by comparing against a verified snapshot. +/// These tests must be run in RELEASE mode as Swagger generation is disabled in DEBUG mode for performance reasons. +/// </summary> public class SwaggerSnapshotTests : IClassFixture<WebApplicationFactory<Program>> { private readonly WebApplicationFactory<Program> _webApplicationFactory; public SwaggerSnapshotTests(WebApplicationFactory<Program> webApplicationFactory) { _webApplicationFactory = webApplicationFactory; } + /// <summary> + /// Verifies that the current Swagger/OpenAPI specification matches the approved snapshot. + /// This test helps prevent unintended breaking changes to the API contract. + /// </summary> + /// <remarks> + /// To update the snapshot after intentional API changes: + /// 1. Build in RELEASE mode + /// 2. Run the test + /// 3. Review and accept the changes using the Verify tool + /// </remarks> [Fact] public async Task FailIfSwaggerSnapshotDoesNotMatch()
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
src/Digdir.Domain.Dialogporten.WebApi/Digdir.Domain.Dialogporten.WebApi.csproj
(1 hunks)src/Digdir.Domain.Dialogporten.WebApi/Program.cs
(5 hunks)src/Digdir.Library.Dialogporten.WebApiClient/.refitter
(1 hunks)src/Digdir.Library.Dialogporten.WebApiClient/Digdir.Library.Dialogporten.WebApiClient.csproj
(1 hunks)tests/Digdir.Domain.Dialogporten.WebApi.Integration.Tests/Features/V1/SwaggerSnapshotTests.cs
(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
- src/Digdir.Library.Dialogporten.WebApiClient/.refitter
- src/Digdir.Library.Dialogporten.WebApiClient/Digdir.Library.Dialogporten.WebApiClient.csproj
- src/Digdir.Domain.Dialogporten.WebApi/Program.cs
- src/Digdir.Domain.Dialogporten.WebApi/Digdir.Domain.Dialogporten.WebApi.csproj
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build / build-and-test
🔇 Additional comments (1)
tests/Digdir.Domain.Dialogporten.WebApi.Integration.Tests/Features/V1/SwaggerSnapshotTests.cs (1)
43-45
: 🛠️ Refactor suggestionVerify file existence before processing.
Add file existence checks to provide better error messages when files are missing.
+ if (!File.Exists(newSwaggerPath)) + { + throw new FileNotFoundException($"Swagger file not found at {newSwaggerPath}. Ensure you've built the project in RELEASE mode."); + } + await Verify(newSwagger, extension: "json") .UseFileName("swagger") .UseDirectory(swaggerPath);Likely invalid or redundant comment.
tests/Digdir.Domain.Dialogporten.WebApi.Integration.Tests/Features/V1/SwaggerSnapshotTests.cs
Show resolved
Hide resolved
tests/Digdir.Domain.Dialogporten.WebApi.Integration.Tests/Features/V1/SwaggerSnapshotTests.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (1)
tests/Digdir.Domain.Dialogporten.WebApi.Integration.Tests/Features/V1/SwaggerSnapshotTests.cs (1)
46-47
: Enhance DEBUG mode failure message with solution steps.The failure message could be more helpful by providing specific steps to run the test in RELEASE mode.
-Assert.Fail("Swagger snapshot tests are not supported in DEBUG mode. Swagger is NOT generated in DEBUG mode, this is to keep build times low. therefore this test will always fail. Run in RELEASE mode to enable."); +Assert.Fail(@"Swagger snapshot tests are not supported in DEBUG mode. +Reason: Swagger is NOT generated in DEBUG mode to keep build times low. + +To run this test: +1. Switch to RELEASE configuration +2. Rebuild the solution +3. Run the test again");
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tests/Digdir.Domain.Dialogporten.WebApi.Integration.Tests/Features/V1/SwaggerSnapshotTests.cs
(2 hunks)
🔇 Additional comments (2)
tests/Digdir.Domain.Dialogporten.WebApi.Integration.Tests/Features/V1/SwaggerSnapshotTests.cs (2)
5-5
: LGTM! Well-documented warning suppression.The pragma warning suppression for CS1998 is appropriately documented, explaining that synchronous execution is expected in DEBUG mode.
51-54
: LGTM! Clear serializer options configuration.The JSON serializer options are appropriately configured for the sorting functionality, which is necessary for cross-platform deterministic testing.
tests/Digdir.Domain.Dialogporten.WebApi.Integration.Tests/Features/V1/SwaggerSnapshotTests.cs
Outdated
Show resolved
Hide resolved
tests/Digdir.Domain.Dialogporten.WebApi.Integration.Tests/Features/V1/SwaggerSnapshotTests.cs
Show resolved
Hide resolved
Renamed WepApi Integration test to WepApi Unit test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
tests/Digdir.Domain.Dialogporten.WebApi.Unit.Tests/Features/V1/SwaggerSnapshotTests.cs (1)
13-40
: LGTM: Smart approach to conditional compilation.The separation between DEBUG and RELEASE modes is well thought out, preventing unnecessary swagger generation during development while maintaining verification in release builds.
Consider using path utilities for more robust path handling.
The hardcoded path segments could be fragile across different environments.
Consider this improvement:
- var swaggerPath = Path.Combine(rootPath!, "docs/schema/V1"); - var newSwaggerPath = Path.Combine(rootPath!, "src/Digdir.Domain.Dialogporten.WebApi/bin/Release/net9.0/swagger.json"); + var swaggerPath = Path.Combine(rootPath!, "docs", "schema", "V1"); + var newSwaggerPath = Path.Combine(rootPath!, "src", "Digdir.Domain.Dialogporten.WebApi", "bin", "Release", "net9.0", "swagger.json");
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
Digdir.Domain.Dialogporten.sln
(4 hunks)docs/schema/V1/swagger.verified.json
(1 hunks)tests/Digdir.Domain.Dialogporten.WebApi.Unit.Tests/Features/V1/SwaggerSnapshotTests.cs
(1 hunks)tests/Digdir.Domain.Dialogporten.WebApi.Unit.Tests/Utils.cs
(1 hunks)
✅ Files skipped from review due to trivial changes (2)
- tests/Digdir.Domain.Dialogporten.WebApi.Unit.Tests/Utils.cs
- docs/schema/V1/swagger.verified.json
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Dry run deploy infrastructure / Deploy to test
- GitHub Check: build / build-and-test
🔇 Additional comments (4)
tests/Digdir.Domain.Dialogporten.WebApi.Unit.Tests/Features/V1/SwaggerSnapshotTests.cs (2)
3-7
: LGTM: Namespace change aligns with test type.The transition from integration tests to unit tests is properly reflected in the namespace.
43-46
: LGTM: Well-structured JSON serialization configuration.The serialization options are properly configured for consistent formatting.
Digdir.Domain.Dialogporten.sln (2)
66-73
: LGTM: Well-organized project structure for the new WebApiClient.The solution structure follows good practices:
- Client library isolated in dedicated solution folder
- Sample project included for documentation/testing
- Integration tests properly separated
164-175
: LGTM: Project configurations are properly set up.All new projects are correctly configured with Debug/Release configurations and properly nested in their respective solution folders.
Also applies to: 205-208
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (3)
.github/workflows/ci-cd-main.yml (1)
126-126
: Remove trailing whitespace.There are trailing spaces on this line that should be removed.
- +🧰 Tools
🪛 yamllint (1.35.1)
[error] 126-126: trailing spaces
(trailing-spaces)
tests/Digdir.Domain.Dialogporten.WebApi.Unit.Tests/Features/V1/SwaggerSnapshotTests.cs (2)
23-24
: Consider making file paths configurable.Hard-coded paths can be problematic for maintainability and cross-platform compatibility. Consider moving these paths to configuration:
+private const string RelativeSwaggerDocsPath = "docs/schema/V1"; +private const string RelativeSwaggerBuildPath = "src/Digdir.Domain.Dialogporten.WebApi/bin/Release/net9.0/swagger.json"; -var swaggerPath = Path.Combine(rootPath!, "docs/schema/V1"); -var newSwaggerPath = Path.Combine(rootPath!, "src/Digdir.Domain.Dialogporten.WebApi/bin/Release/net9.0/swagger.json"); +var swaggerPath = Path.Combine(rootPath!, RelativeSwaggerDocsPath); +var newSwaggerPath = Path.Combine(rootPath!, RelativeSwaggerBuildPath);
10-44
: Appropriate architectural shift from integration to unit testing.The transition from integration tests to unit tests is well-executed. The conditional compilation effectively manages the different testing requirements between DEBUG and RELEASE modes, while maintaining the core functionality of Swagger documentation verification.
Consider documenting this architectural decision in the project's documentation to help other developers understand:
- Why the shift from integration to unit testing was made
- When to run tests in RELEASE mode
- The relationship between these tests and the npm package publication process
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.github/workflows/ci-cd-main.yml
(2 hunks)tests/Digdir.Domain.Dialogporten.WebApi.Unit.Tests/Features/V1/SwaggerSnapshotTests.cs
(1 hunks)
🧰 Additional context used
🪛 yamllint (1.35.1)
.github/workflows/ci-cd-main.yml
[error] 126-126: trailing spaces
(trailing-spaces)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Dry run deploy infrastructure / Deploy to test
- GitHub Check: build / build-and-test
🔇 Additional comments (4)
.github/workflows/ci-cd-main.yml (2)
45-50
: LGTM! Secrets are well-structured and properly scoped.The new secrets for Maskinporten and ED25519 keys follow consistent naming conventions and are properly referenced.
125-125
: Make secret name environment agnostic.Remove the environment suffix from the secret name to make it reusable across environments.
- NUGET_API_KEY: ${{ secrets.NUGET_API_TEST_KEY }} + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}tests/Digdir.Domain.Dialogporten.WebApi.Unit.Tests/Features/V1/SwaggerSnapshotTests.cs (2)
1-8
: LGTM! Appropriate compiler directive usage and namespace change.The compiler directive correctly suppresses CS1998 in DEBUG mode, and the namespace accurately reflects the transition from integration to unit testing.
47-50
: LGTM! Well-structured JSON serialization configuration.The JsonSerializerOptions configuration with WriteIndented = true is appropriate for generating readable and consistent JSON output.
tests/Digdir.Domain.Dialogporten.WebApi.Unit.Tests/Features/V1/SwaggerSnapshotTests.cs
Outdated
Show resolved
Hide resolved
src/Digdir.Domain.Dialogporten.WebApi/Digdir.Domain.Dialogporten.WebApi.csproj
Outdated
Show resolved
Hide resolved
"Maskinporten": { | ||
"ClientId": "ce3b732a-d4f2-4997-8545-adf8df70fe6c", | ||
"Scope": "digdir:dialogporten.serviceprovider digdir:dialogporten.serviceprovider.search", | ||
"EncodedJwk": "eyJwIjoieTRBZEhlVVBxdFEtSFlOWkR5ci0zS09RT3NQajA5TFh2a2hIUFlTdGFYNThkMndIWUJiVXlDTWdMYWtGTHo4UExKNWtscURsanRoczFtM1dFVGJhSWVuY25TalpjZTh4S1Q2SHh3bTNyaDlydWZ1TWVOZDRqaFptTm9WZmJrcGNXcVh0UDFvb1NPTE5zYUNVUWFUUEVKTXlFd3VhdWxMSzgxRG1SSTlMSmVNIiwia3R5IjoiUlNBIiwicSI6InFmOEQ2Uy1Kd19BdVQ0Q2hjQTlDek9WNk1uTW9mc1VCdTkteHJBcVFDRjh4WWZZOTRxQ1ZjQ3llajlkTlN3eXZUZXg1dThIMzNSaU1LMEFWM2tTQlpJLVZqcXJHLUx6YzNfTUlTTVpSVDJfbzNVQlRWVHpqTkUtSkpMX1hKaXJ6ZVhhQjM1UmFZMjFnWVhKQWg3X2tuR3dpRzF3MGxiT2ozQ0FzdnVwaU1BMCIsImQiOiJLVkF1b1Zhd2paTTgwenRYcUxSZUJGZkJ3M3pxVjdkUGFpaWFONWU0RFp6bW5MYTFMNEZJMTgtanVraHN4UVdqR1NFQnBIdTFrOHRPUWMyWjBsSDVaaTBydERqM0JKeEhxeDNsUGdYMWdTNXNiX1EyeXNfb2FKcklSX012MHBDQUFHX3hpa2lUY2kzTHMyeV9femV4QTdLbG0yalNmYW9Udzdhbml1R3RId1d5dHhCSnJnZ0J2c3loaHZIaUVQcnZaMHZBZldYYWI3QUtkUjc1cEtEaVVHOGdGNTdJN0hrWnpJSk9QYXp3MTU1Skx4TG9HcDVzeTFCVVpBNHRiQmlseWVsdG9ONGZINWd1aUktOXJjTE5zUmVYazJ1c3NFbE9EbVZ2Qmx2ZVVfb1ZRMVYtVDRJRnUzZk1BYVJGUFA2Wlo1akJJX2hkOFJOTTJ3eUp5UHVRWVEiLCJlIjoiQVFBQiIsInVzZSI6InNpZyIsImtpZCI6ImRpYWxvZ3BvcnRlbi1zcC1zZGstdGVzdC0yMDI0MTAxMCIsInFpIjoiQm9VS0RlczQ0UTNpXzNyT3Q4aHRrS2NxWkFNem00Njl2cTZuQnJVcHBTU1Ric3YwalZwN1daRGRRR0Q0bU8yMVJVOEFUbmN3NjFPOUt3YXktOGloX082VWFWbGxZN3NHYlVrQ2NVaG43ZDkzSElLZnhybnhWVE9nNUNMWTBka2Zwa3A1V2pyU1VvMTVKQURsY3BRM0ItRlU0Nm9PTG9ydjJ0SVFQekE4OF93IiwiZHAiOiJ1emVaRWZpN2Fqa3JFREhYekZtTThXWFUtZ3RmM1ctN0pnY082MnpWc1JrNTN4QlcxTE1NZlRlN2tlWk9xOEhDN3hTbGktSm9idnR6WGU3Y295ZW9sTXkzTnlydXFhQVp4VTBPMHpHQWQ4UFdjdHNXeDlITHlrU1hNby1QVlVNNkpmZERCaWFtcXk5bGQ0WTRfdzlscEdVWEMyaUFwLXdsWktaSHdrbG1KR3MiLCJhbGciOiJSUzI1NiIsImRxIjoiVENBcV9DMlJuX0RhakRlcUU2aUIzWWVWNVNtMHBMQk1Tbm10OHNENEp3ZVo4YWgzcGhrTFVxUm9qVGw1SDNhYXVtWl9UUmxiaWVNSVFnWDh4UUFnZ1l2YkNYeG9oZEx0aGt3ckZZdlp0WjBEeHJDYm9Md1hjc0Y3Ukwyejl4LWMwSFBGVFAzLVREQWF6UWlBNVVtRmNwYnAzeDYzWGFLSWFuYnVFc0NiSDdFIiwibiI6Imh5Sks4WnE2Wk8tRjFSSklVWVNCdUpfeG9RWkNNV1EyTVhrSFQ1bVROVVJJZmVWWWpCNWMwMzI0Uk5nc3ZPMEtXX0hUejRRSnptLV9rU1VaZ0h1Z2JoR0F3a1Vqc1lwTlJJRTBvLVNtdEExMlMxZHVCZWx6ajg2LVFrZkFzeFlwblNnSzl5OXpTS1B0YVlzMS1EcEVIb0hVdk9BSDJlNktFTXRaYUZPM0J0Yk9WUURXMENMYi1FY0UyaDBQRlFMMUp3NU8zeDhHcXBZeUFhamNoWnptcWlFbjBaSEd1QTNZZ1NyNGxQV1lkTzBNWHZmRFdyaFBTcnVTS3FodzBHMTlBRUpHOFhoek9xTWxLTUFIbW5ybk9XOHM2cWR2Sy1UQ1BiVGJJOU5XUWdFd2JpUFBBdlU0MUFITzZmTEYxUHZzQ3FhNjZTSGdYMkJzS3pvNVhORjhodyJ9" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dette er en hemmelighet som ikke burde sjekkes inn. Nå som det først er gjort burde denne klientens JWK bli rotert slik at den som står her nå blir invalid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hadde klart å sjekket inn Ed25519Keys tidligere, etter @oskogstad fant det fjernet jeg commiten med squash. men burde da sikkert rotere de også?
src/Digdir.Library.Dialogporten.WebApiClient/Digdir.Library.Dialogporten.WebApiClient.csproj
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/Digdir.Domain.Dialogporten.WebApi/Program.cs (2)
107-126
: Consider adding null-safety checks for ApplicationSettings.
Although the code uses the null-forgiving operator (!
) when obtainingApplicationSettings
, it's safer to validate that the configuration exists and fail gracefully if it's missing or malformed. This approach improves robustness, especially if future deployments or environments lack the required settings.
208-208
: Review environment-based configuration.
The logic here uses an environment check for local vs. production to set up the Swagger document path. Consider centralizing environment checks in one place (for instance, near thedialogportenBaseUri
logic) to maintain consistency and reduce confusion about where environment-based overrides apply.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
Digdir.Domain.Dialogporten.sln
(4 hunks)src/Digdir.Domain.Dialogporten.WebApi/Digdir.Domain.Dialogporten.WebApi.csproj
(2 hunks)src/Digdir.Domain.Dialogporten.WebApi/Program.cs
(2 hunks)src/Digdir.Library.Dialogporten.WebApiClient.Sample/Dialogs.cs
(1 hunks)src/Digdir.Library.Dialogporten.WebApiClient/Digdir.Library.Dialogporten.WebApiClient.csproj
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- src/Digdir.Library.Dialogporten.WebApiClient.Sample/Dialogs.cs
- src/Digdir.Library.Dialogporten.WebApiClient/Digdir.Library.Dialogporten.WebApiClient.csproj
- src/Digdir.Domain.Dialogporten.WebApi/Digdir.Domain.Dialogporten.WebApi.csproj
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Dry run deploy infrastructure / Deploy to test
- GitHub Check: build / build-and-test
🔇 Additional comments (4)
Digdir.Domain.Dialogporten.sln (4)
52-52
: Welcome addition of unit tests.
Adding theDigdir.Domain.Dialogporten.WebApi.Unit.Tests
project is a good step toward solidifying test coverage. Ensure that the new test project references the correct assemblies and includes an initial set of meaningful test cases for the Web API.
66-71
: New client library projects - good structure.
The addition of these projects appears well-organized and consistent with the solution’s existing layout. Confirm that the references between these libraries align with the intended dependency graph (e.g., sample driving the main library, etc.).
162-169
: No issues found with Debug/Release configurations.
These lines simply ensure that the new projects build properly under standard configurations. Everything looks correct here.
199-201
: Solution folder nesting is logical.
The added references for the new projects under the “WebApiClient” folder help keep the solution neatly organized. No concerns identified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
tests/Digdir.Domain.Dialogporten.WebApi.Unit.Tests/Features/V1/SwaggerSnapshotTests.cs (1)
23-25
: Enhance file path handling and validation.While the file existence check is present, the path handling could be more robust:
var swaggerPath = Path.Combine(rootPath!, "docs/schema/V1"); -var newSwaggerPath = Path.Combine(rootPath!, "src/Digdir.Domain.Dialogporten.WebApi/bin/Release/net9.0/swagger.json"); -Assert.True(File.Exists(newSwaggerPath), $"Swagger file not found at {newSwaggerPath}. Make sure you have built the project in RELEASE mode."); +var newSwaggerPath = Path.Combine(rootPath!, "src", "Digdir.Domain.Dialogporten.WebApi", "bin", "Release", "net9.0", "swagger.json"); + +if (!Directory.Exists(Path.GetDirectoryName(newSwaggerPath))) +{ + throw new DirectoryNotFoundException( + $"Release build directory not found. Please ensure you've built the project in Release mode. Expected path: {Path.GetDirectoryName(newSwaggerPath)}"); +} + +if (!File.Exists(newSwaggerPath)) +{ + throw new FileNotFoundException( + $"Swagger file not found at {newSwaggerPath}. This could indicate a build configuration issue or missing swagger generation step.", + newSwaggerPath); +}
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tests/Digdir.Domain.Dialogporten.WebApi.Unit.Tests/Features/V1/SwaggerSnapshotTests.cs
(1 hunks)
🔇 Additional comments (3)
tests/Digdir.Domain.Dialogporten.WebApi.Unit.Tests/Features/V1/SwaggerSnapshotTests.cs (3)
1-8
: LGTM! Appropriate use of pragma directive.The pragma directive is correctly used to suppress the CS1998 warning in DEBUG mode where the async method intentionally lacks await operators. The namespace change accurately reflects the transition to unit testing.
14-45
: LGTM! Well-structured test with clear mode-specific behaviors.The conditional compilation effectively manages different test behaviors between DEBUG and RELEASE modes, with clear documentation of the purpose and limitations.
48-51
: LGTM! Appropriate JSON serialization configuration.The JsonSerializerOptions are correctly configured with WriteIndented = true, which ensures readable JSON output in test snapshots.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/Digdir.Library.Dialogporten.WebApiClient.Sample/appsettings.json (1)
1-16
: Add documentation for configuration valuesWhile using empty strings is secure, consider adding comments or documentation to guide developers on:
- Required format and structure for each value
- How to obtain valid values
- Environment-specific considerations
Would you like me to help create a documentation template for the configuration values?
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/Digdir.Library.Dialogporten.WebApiClient.Sample/appsettings.json
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Dry run deploy infrastructure / Deploy to test
- GitHub Check: build / build-and-test
🔇 Additional comments (2)
src/Digdir.Library.Dialogporten.WebApiClient.Sample/appsettings.json (2)
3-3
: Verify supported environment valuesThe environment is set to "local". Please ensure that:
- All supported environment values are documented
- This default value aligns with local development setup
✅ Verification successful
Environment configuration is valid and documented
The value "local" is a valid environment setting that maps to the test environment internally. This is intentionally configured for local development and properly documented in the project's setup guide.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for environment value validation or usage rg -A 5 "Environment.*local" --type csLength of output: 40
Script:
#!/bin/bash # Search for Environment configuration usage rg -i "environment" --type cs -A 5 # Look for configuration model classes ast-grep --pattern 'class $_ { $$$ Environment $$$ }' # Check documentation cat README.md 2>/dev/null || echo "README not found"Length of output: 81313
4-8
: Maintain secure configuration practicesGood to see empty values for sensitive Maskinporten configuration. To prevent future security issues:
- Add this file to security scanning workflows
- Document the process for securely managing these values
✅ Verification successful
✅ Security practices are well-established
The empty Maskinporten configuration values align with the project's documented security practices. The repository follows a robust security model where:
- Sensitive values are managed through Azure Key Vault
- Configuration documentation explicitly covers secure handling of credentials
- Empty template values prevent accidental credential exposure
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Check if security scanning is configured fd -g "*security*.yml" .github/workflows/Length of output: 43
Script:
#!/bin/bash # Check if workflows directory exists and list its contents echo "=== Checking workflows ===" ls -la .github/workflows/ 2>/dev/null || echo "No .github/workflows directory found" echo -e "\n=== Checking for security documentation ===" # Look for security-related documentation fd -e md -e txt -H -I | xargs rg -i "security|maskinporten|configuration" -l || echo "No matching documentation found"Length of output: 2798
Script:
#!/bin/bash echo "=== Checking Configuration.md ===" cat docs/Configuration.md echo -e "\n=== Checking WebApiClient README ===" cat src/Digdir.Library.Dialogporten.WebApiClient/README.mdLength of output: 16289
"Ed25519Keys": { | ||
"Primary": { | ||
"Kid": "", | ||
"PublicComponent": "" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Document key management procedures and implement key lifecycle management
The codebase shows proper key storage practices using secrets management, but lacks critical documentation and implementation for key lifecycle management. Required actions:
- Document the usage of
Digdir.Tool.Dialogporten.Ed25519KeyPairGenerator
for key generation - Implement and document key rotation procedures
- Define monitoring strategy for key expiration
- Document backup and recovery processes
- Consider implementing automated key rotation capabilities
🔗 Analysis chain
Document key management procedures
Given the previous discussion about key rotation, please ensure:
- Key rotation procedures are documented
- Monitoring is in place for key expiration
- Backup and recovery processes are defined
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for key management documentation
fd -g "README*" -X grep -l "key rotation\|key management"
Length of output: 59
Script:
#!/bin/bash
# Search for documentation files containing key-related terms
rg -i "key (rotation|management|expiration)" -g "*.{md,txt,doc,docs}"
# Search for key configuration patterns
rg -i "ed25519|keys?:" -A 5 -g "*.{json,yaml,yml}"
# Search for key management implementation
ast-grep --pattern 'class $_ {
$$$
(Rotate|Update|Manage)Keys($$$) {
$$$
}
$$$
}'
Length of output: 12669
Description
Related Issue(s)
Verification
Documentation
docs
-directory, Altinnpedia or a separate linked PR in altinn-studio-docs., if applicable)