Skip to content

feat(gateway): Verify bearer token signatures - #32

Draft
kprabhak wants to merge 1 commit into
chore/connect-preview-28from
feat/token-signatures
Draft

kprabhak wants to merge 1 commit into
chore/connect-preview-28from
feat/token-signatures

Conversation

@kprabhak

Copy link
Copy Markdown

Summary

The gateway is meant to admit devices by a bearer token from an issuer its operator configures, checked locally with no call to another service.

This adds the first part: issuers and their keys in the configuration, checked when it loads, and signature verification with the algorithm fixed by the key. It uses the jsonwebtoken library with the aws-lc backend the gateway already builds.

Nothing uses it until the token admission pull request, the third in this stack.

Test plan

  • Ed25519, P-256 and RSA signatures verify, and a token signed with another key or algorithm is refused
  • One unusable key, including one with secret-key members, rejects the whole configuration when it loads
  • Format, lint and tests pass

Related to datum-cloud/enhancements#883 and datum-cloud/enhancements#916

The gateway is meant to admit devices by a bearer token from an
issuer its operator configures, checked locally with no call to any
service. This adds the first part of that check: parsing a token and
verifying its signature against the issuer's keys.

Each configured issuer appears once and lists its keys as a JSON Web
Key Set. The keys are checked when the configuration loads: Ed25519,
P-256 and RSA of at least 2048 bits only, never a shared-secret
("oct") key or another curve; "use" equal to "sig" when present; "alg"
matching the key type; a unique "kid"; and no secret-key members
("d", "p", "q", "dp", "dq", "qi", "oth", "k"). An RSA key needs an
exponent. One unusable key refuses the whole
configuration, so a renderer can rely on every listed key being used.

The signing algorithm is fixed by the selected key, never taken from
the token, so a token signed with another algorithm is refused. A
token names its key by "kid", or its issuer must have exactly one key.
A token longer than 8 KiB, or with a "crit" header, is refused before
any other check.

Signatures are verified with the jsonwebtoken crate and its aws-lc
backend, which the gateway already builds through rustls. The crate
accepts shared-secret keys and does not check curves, so the key
checks above run before it sees a key. Nothing calls the verifier
yet; token admission uses it.

Tests cover each refusal, including shared-secret and wrong-curve
keys, a key with secret-key members, and an oversize token.
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.

1 participant