feat(security): add signed URL generator (closes #161)#195
Merged
Conversation
Adds ISignedUrlGenerator with HMAC-strength authenticated signing via IDataProtectionProvider, plus a RequireSignedUrl endpoint filter that returns 403 on tamper/expiry/purpose mismatch. Signatures are bound to an optional purpose tag to prevent reuse across endpoints. Validation uses FixedTimeEquals.
- Reject URLs that carry a purpose when the validator wasn't told to expect one (and vice-versa). Previously a purpose-bound token would pass an endpoint that didn't specify the purpose, defeating the binding. - Catch InvalidOperationException from IDataProtector.Unprotect alongside CryptographicException / FormatException so malformed signatures always 403 instead of 500ing. - Reject paths containing '?' at sign time so the canonical can never diverge between Sign and TryValidate. - Replace the public string Items key with a typed HttpContext.GetSignedUrlClaims() accessor. - Drop the dead PathString.HasValue ternary; routing guarantees a value.
Deploying simplemodule-website with
|
| Latest commit: |
2e8bae4
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://a4c7836f.simplemodule-website.pages.dev |
| Branch Preview URL: | https://claude-fix-simple-issues-4jh.simplemodule-website.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements
ISignedUrlGeneratorfor tamper-proof, expiring URLs (#161).ISignedUrlGenerator+SignedUrlClaimsinframework/SimpleModule.Core/Security.IDataProtectionProvider(handles key rotation automatically).RequireSignedUrl(purpose?)endpoint filter — returns 403 on tamper / expiry / purpose mismatch, stashesSignedUrlClaimsinHttpContext.Items.expiresandpurposebound into the signature.CryptographicOperations.FixedTimeEquals.TimeProvider.Systemand the generator inSimpleModuleHostExtensions.Acceptance criteria from #161
ISignedUrlGeneratorinSimpleModule.CoreRequireSignedUrl(purpose?)endpoint filterTest plan
dotnet test tests/SimpleModule.Core.Tests --filter SignedUrlGeneratorTests→ 13/13 passdotnet test tests/SimpleModule.Core.Tests→ 210/210 passdotnet build framework/SimpleModule.Hosting→ cleanGenerated by Claude Code