Skip to content

Update token signers to use HMAC signature and add tests#19

Merged
dbContext merged 8 commits into
masterfrom
upgrade-clients
Apr 2, 2026
Merged

Update token signers to use HMAC signature and add tests#19
dbContext merged 8 commits into
masterfrom
upgrade-clients

Conversation

@Jonno12345

Copy link
Copy Markdown
Contributor

Overhaul to all signers to bring them all in line and accurate, using latest signature pattern.

Updated readme and added CI tests.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread python3/token.py Outdated
Comment thread README.md Outdated
Comment thread README.md
Comment thread java/src/main/java/BunnyCDN/TokenSigner.java
Comment thread php/url_signing.php
Comment thread .github/workflows/tests.yml
@dbContext dbContext merged commit 8840cb1 into master Apr 2, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants