Skip to content

Commit b9523db

Browse files
authored
Merge pull request #27 from dhensby/pulls/refactor
Maturing the API
2 parents 3238685 + b8ff6e9 commit b9523db

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+10370
-793
lines changed

.github/workflows/nodejs.yml

+21-4
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,41 @@ jobs:
1717
lint:
1818
name: Linting check
1919
runs-on: ubuntu-latest
20+
timeout-minutes: 1
2021
steps:
2122
- uses: actions/checkout@v3
2223
with:
2324
persist-credentials: false
2425
- name: Code linting
2526
uses: actions/setup-node@v2
2627
with:
27-
node-version: 12.x
28+
node-version: 14.x
2829
cache: 'npm'
2930
- run: npm ci
3031
- run: npm run lint
31-
32+
# coverage:
33+
# name: Coverage check
34+
# runs-on: ubuntu-latest
35+
# steps:
36+
# - uses: actions/checkout@v2
37+
# - name: Code coverage
38+
# uses: actions/setup-node@v2
39+
# with:
40+
# node-version: 12.x
41+
# cache: 'npm'
42+
# - run: npm ci
43+
# - run: npm run test:coverage
44+
# - name: Code Coverage Report
45+
# uses: romeovs/lcov-reporter-action@v0.2.11
3246
tests:
3347
name: Unit tests
48+
needs:
49+
- lint
3450
runs-on: ubuntu-latest
51+
timeout-minutes: 1
3552
strategy:
3653
matrix:
37-
node-version: [12.x, 14.x, 16.x, 18.x]
54+
node-version: [14.x, 16.x, 18.x]
3855
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
3956
steps:
4057
- uses: actions/checkout@v3
@@ -46,4 +63,4 @@ jobs:
4663
node-version: ${{ matrix.node-version }}
4764
cache: 'npm'
4865
- run: npm ci
49-
- run: npm test
66+
- run: npm run test:coverage

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
/lib/
22
/node_modules/
3+
/.nyc_output/
4+
/coverage/

.nycrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"all": true,
3+
"extension": [".ts"],
4+
"include": ["src/**"]
5+
}

README.md

+52-6
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,61 @@ of HTTP messages before being sent.
99

1010
Two specifications are supported by this library:
1111

12-
1. [HTTPBIS](https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-message-signatures-06#appendix-B.2)
13-
2. [Cavage](https://datatracker.ietf.org/doc/html/draft-cavage-http-signatures-12)
12+
1. [HTTPbis](https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-message-signatures)
13+
2. [Cavage](https://datatracker.ietf.org/doc/html/draft-cavage-http-signatures) and subsequent [RichAnna](https://datatracker.ietf.org/doc/html/draft-richanna-http-message-signatures)
1414

1515
## Approach
1616

17-
As the cavage specification is now expired and superseded by the HTTPBIS one, this library takes a
18-
"HTTPBIS-first" approach. This means that most support and maintenance will go into the HTTPBIS
19-
implementation and syntax. The syntax is then back-ported to the Cavage implementation as much as
20-
possible.
17+
As the Cavage/RichAnna specification is now expired and superseded by the HTTPbis one, this library takes a
18+
"HTTPbis-first" approach. This means that most support and maintenance will go into the HTTPbis
19+
implementation and syntax. The syntax is then back-ported to the as much as possible.
20+
21+
## Caveats
22+
23+
The Cavage/RichAnna specifications have changed over time, introducing new features. The aim is to support
24+
the [latest version of the specification](https://datatracker.ietf.org/doc/html/draft-richanna-http-message-signatures)
25+
and not to try to support each version in isolation.
26+
27+
## Limitations in compliance with the specification
28+
29+
As with many libraries and environments, HTTP Requests and Responses are abstracted away from the
30+
developer. This fact is noted in the specification. As such (in compliance with the specification),
31+
consumers of this library should take care to make sure that they are processing signatures that
32+
only cover fields/components whose values can be reliably resolved. Below is a list of limitations
33+
that you should be aware of when selecting a list of parameters to sign or accept.
34+
35+
### Derived component limitations
36+
37+
Many of the derived components are expected to be sourced from what are effectively http2 pseudo
38+
headers. However, if the application is not running in http2 mode or the message being signed is
39+
not being built as a http2 message, then some of these pseudo headers will not be available to the
40+
application and must be derived from a URL.
41+
42+
#### @request-target
43+
44+
The [`@request-target`](https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-message-signatures#section-2.2.5)
45+
component is intended to be the equivalent to the "request target portion of the request line".
46+
See the specification for examples of what this means. In NodeJS, this line in requests is automatically
47+
constructed for consumers, so it's not possible to know for certainty what this will be. For incoming
48+
requests, it is possible to extract, but for simplicity’s sake this library does not process the raw
49+
headers for the incoming request and, as such, cannot calculate this value with certainty. It is
50+
recommended that this component is avoided.
51+
52+
### Multiple message component contexts
53+
54+
As described in [section 7.4.4](https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-message-signatures#section-7.4.4)
55+
it is deemed that complex message context resolution is outside the scope of this library.
56+
57+
This means that it is the responsibility of the consumer of this library to construct the equivalent
58+
message context for signatures that need to be reinterpreted based on other signer contexts.
59+
60+
61+
### Padding attacks
62+
63+
As described in [section 7.5.7](https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-message-signatures-13#section-7.5.7)
64+
it is expected that the NodeJS application has taken steps to ensure that headers are valid and not
65+
"garbage". For this library to take on that obligation would be to widen the scope of the library to
66+
a complete HTTP Message validator.
2167

2268
## Examples
2369

0 commit comments

Comments
 (0)