Update token signers to use HMAC signature and add tests#19
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR standardizes BunnyCDN token URL signing across multiple language implementations by switching to an HMAC-SHA256-based signature format, adds cross-language deterministic test vectors, and introduces CI to run the new test suites.
Changes:
- Updated signers (C#, Python, Node.js, PHP, Java) to generate
HS256-prefixed base64url (no padding) HMAC-SHA256 tokens. - Added/updated unit tests in each language to validate identical expected signed URLs.
- Added GitHub Actions workflow and language-specific test dependencies/config (pytest, node:test, PHPUnit, Maven/JUnit).
Reviewed changes
Copilot reviewed 22 out of 24 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | New consolidated documentation for token format, parameters, and quick starts. |
| python3/token.py | Rewritten Python signer using HMAC-SHA256 with parameter sorting and validation. |
| python3/test_token.py | Adds pytest coverage with fixed-time expectations for multiple signing scenarios. |
| python3/requirements-test.txt | Declares pytest as the Python test dependency. |
| php/url_signing.php | Rewritten PHP signer using HMAC-SHA256 with stricter query parsing/validation. |
| php/tests/TokenSignerTest.php | Adds PHPUnit test vectors aligned with other languages. |
| php/phpunit.xml | PHPUnit configuration for running the new PHP tests. |
| php/composer.json | Adds PHPUnit as a dev dependency and autoloads the signer file. |
| nodejs/token.js | Rewritten Node signer using HMAC-SHA256 with sorted parameters and validations. |
| nodejs/token.test.js | Adds node:test-based test vectors aligned with other languages. |
| nodejs/package.json | Adds a Node test script for CI/local runs. |
| java/src/main/java/BunnyCDN/TokenSigner.java | New Maven-structured Java signer using HMAC-SHA256 and sorted params. |
| java/src/test/java/BunnyCDN/TokenSignerTest.java | Adds JUnit test vectors aligned with other languages. |
| java/src/BunnyCDN/TokenSigner.java | Removes the legacy Java implementation (and external deps) in favor of the new one. |
| java/pom.xml | Introduces Maven build/test configuration with JUnit Jupiter. |
| java/EXAMPLES/Example.java | Updates example usage to the new static signing API. |
| c#/BunnyCDN.TokenAuthentication/BunnyCDN.TokenAuthentication/TokenSigner.cs | Replaces old hashing approach with HMAC-SHA256, adds ignore-params and query parsing logic. |
| c#/BunnyCDN.TokenAuthentication/BunnyCDN.TokenAuthentication/TokenConfig.cs | Adds IgnoreParams and defaults UserIp to empty string. |
| c#/BunnyCDN.TokenAuthentication/BunnyCDN.TokenAuthentication/BunnyCDN.TokenAuthentication.csproj | Removes Flurl dependency; targets net6.0 + netstandard2.0. |
| c#/BunnyCDN.TokenAuthentication/BunnyCDN.TokenAuthentication.Tests/TokenSignerTests.cs | Updates expected tokens and adds additional scenario/validation tests. |
| c#/BunnyCDN.TokenAuthentication/BunnyCDN.TokenAuthentication.Tests/BunnyCDN.TokenAuthentication.Tests.csproj | Updates test target frameworks and normalizes project formatting. |
| .github/workflows/tests.yml | Adds CI jobs to run tests across C#, Python, Node.js, PHP, and Java. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
dbContext
approved these changes
Apr 2, 2026
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.
Overhaul to all signers to bring them all in line and accurate, using latest signature pattern.
Updated readme and added CI tests.