Add a Go signing client - #127
Open
beetlebugorg wants to merge 2 commits into
Open
Conversation
Package moddims at clients/moddims signs /dims4/ and /dims5/ URLs and encrypts an image URL into eurl. Go 1.24, and no dependency outside the standard library. The package reads the raw query itself and decodes each part with url.PathUnescape. url.ParseQuery reads a plus in url as a space and reports an error on a semicolon, and the module does neither. url.Values.Encode writes the canonical query, because it sorts by the bytes of the name and keeps the order of the values under one name. fixture_test.go reads test/fixtures/signing.tsv and runs every record as a subtest. sign_test.go covers what a record cannot: an empty key, the escape table url.QueryEscape produces, and a fresh IV on every GCM call.
clients.yml runs go vet, go test, and gofmt from clients/moddims on a change under clients/ or test/fixtures/. A job cannot filter on paths, so the clients take a workflow of their own. docs-pr.yml has the same shape. pr.yml adds clients/** to its paths-ignore, so a change under clients/ runs neither the module build nor the goldens. docs/docs/clients/go.md states the import path, the prefix, the sentinels, and the tag form. A Go module in a subdirectory publishes under clients/moddims/v1.0.0.
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.
What
Package
moddimsatclients/moddimssigns/dims4/and/dims5/URLs and encrypts an image URL intoeurl. Go 1.24, and no dependency outside the standard library.Dims5andDims4each have aSignmethod and aSignEncryptedmethod.DeriveKey,Encrypt, andDecryptdo the eurl steps on their own.clients.ymlis a new workflow that runsgo vet,go test, andgofmtfromclients/moddimson a change underclients/ortest/fixtures/. A job cannot filter on paths, so the clients have a workflow of their own.pr.ymladdsclients/**to itspaths-ignore, so a change underclients/runs neither the module build nor the goldens.docs/docs/clients/go.mdstates the import path, the prefix, the sentinels, and the tag form.Why
Stacked on #126, which adds the C library and
test/fixtures/signing.tsv.Issue #124. The signing rules had four copies in this repository and a fifth in go-dims. A Go caller could reach none of them.
The package reads the raw query itself and decodes each part with
url.PathUnescape.url.ParseQueryreads a plus inurlas a space and reports an error on a semicolon, and the module does neither.url.Values.Encodewrites the canonical query, because it sorts by the bytes of the name and keeps the order of the values under one name.Verify
57 cases pass.
fixture_test.goruns all 42 records fromtest/fixtures/signing.tsvas subtests, so a failure names the case.Change one character of a signature in that file, and
TestFixtures/dims5-plainfails with the two values.