voltone

voltone

Plug for verifying request signatures according to the IETF HTTP signatures draft specification.

Supports the following algorithms:

  • “hs2019”, using ECDSA, RSASSA-PSS or HMAC
  • “rsa-sha256”, using RSASSA-PKCS1-v1_5
  • “ecdsa-sha256”
  • “hmac-sha256”
  • “rsa-sha1”, using RSASSA-PKCS1-v1_5

Hex: https://hex.pm/packages/plug_signature
Hexdocs: https://hexdocs.pm/plug_signature/
GitHub: https://github.com/voltone/plug_signature

Signing the request body requires use of the HTTP Digest header, which can be added through the following package:

Hex: https://hex.pm/packages/plug_body_digest
Hexdocs: https://hexdocs.pm/plug_body_digest/
GitHub: https://github.com/voltone/plug_body_digest

A very simple sample app using both plugs is available in the PlugSignature GitHub repo. This code also includes two client implementations (one in Elixir using Tesla, and one as a shell script using OpenSSL/cURL) for testing.

Showing Posts 1 to 3

tangui

tangui

Hi Voltone,

Great work! I’m very curious about the use-case it solves, if it’s no secret. I remember having to choose between such a scheme and signed JWT (which transforms the JSON payload to a base64 payload, is heavier, etc.). We finally chose not using this HTTP signature mainly because of a host of proxies that would have inevitably modified some signed headers and lack of implementation.

Also, I see you support RSA with PSS padding. So far I thought it wasn’t supported by Erlang. That’s good news! Thanks for the code and comment that goes with it, I’ll you use it soon :slight_smile:

anthonator

anthonator

From the IETF draft:

When communicating over the Internet using the HTTP protocol, it can
be desirable for a server or client to authenticate the sender of a
particular message. It can also be desirable to ensure that the
message was not tampered with during transit. This document
describes a way for servers and clients to simultaneously add
authentication and message integrity to HTTP messages by using a
digital signature.

It looks like this is similar to how companies like Shopify and GitHub allow you to verify the content of a payload by signing the body of the HTTP request with a private/secret key. I’ve seen this used mostly with webhooks. Apologies if that’s incorrect.

Looks awesome though!

voltone

voltone OP

Leaving aside projects where the use of this standard is prescribed, e.g. due to integration or compliance requirements…

Compared to other authentication mechanisms that work at the HTTP layer, signatures offer a number of benefits:

  • Credentials are not transmitted on the wire, unlike Basic or Bearer auth; this is generally a good thing regardless of whether the channel is encrypted
  • It does not require a challenge/response roundtrip and keeping state on the server, unlike Digest auth
  • It verifies the integrity of selected parts of the HTTP request, preventing modification of those parts by intermediaries
  • Support for non-repudiation (except when using HMAC)
  • Private key never leaves the client, so it is less likely to leak compared to symmetrical credentials that need to be defined in client and server (again, does not apply to HMAC)

Compared to authentication at the TLS layer, e.g. a client certificate:

  • Does not impose requirements on TLS proxies (e.g. cloud load balancers)
  • Works with browser-based clients

Of course you could implement the whole thing in a higher layer, using HTTP only as a dumb pipe. I generally try to avoid pushing functionality up the stack, preferring to leverage the services of lower layers (in this case HTTP) and handling only my business logic in the application layer. This allows me to delegate things like authentication and authorisation (e.g. to Plugs or API gateways) without impacting my APIs.

As for headers being manipulated between client and server, this hasn’t been an issue for me: headers that are likely to be modified often do not require integrity protection. In earlier versions of the spec the Date header was included in the signature, to limit the signature validity, and this could be problematic (also for AJAX clients), but the latest drafts use the created/expires parameters of the signature header instead.

— All posts loaded —

Where Next? Top

Trending in Announcing Top

woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
MRdotB
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. https://github.com/woylie/doggo Features Unstyled Phoenix components....
New
GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
ahamez
Hi everyone, I’ve been working on this protobuf library for 3 years. We use it in the company I work for, EasyMile, to communicate with ...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
AstonJ
This showed up on my feed.. anyone heard of it? Just hype? Ox Alpha is a reasoning model designed for coding, sustained ag...
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews