Skip to content

Latest commit

 

History

History
38 lines (28 loc) · 2.73 KB

README.md

File metadata and controls

38 lines (28 loc) · 2.73 KB

SignedAccess

CodeQL Test Coverage JavaScript Style Guide Conventional Commits

Sign and verify URLs and cookies to add a layer of protection to publicly accessible routes

Which is?

A signed URL or signed cookie provides limited time and permission for non-credentialed origins to perform a number of specific actions on one resource or several based on a common prefix. The subscription ensures that the permissions for a particular resource are not modified or tampered with.

Features

  • Sign and verify URL and cookie
  • Freedom of choice in algorithm and encryption key
  • Access validity time
  • Possibility of using IP to prevent unauthorized access
  • Possibility to restrict which HTTP methods can be used in the request
  • Possibility to use nonce values to prevent replay attacks
  • Possibility to allow access to multiple URLs based on a common prefix

Interfaces

Although this is a javascript module, we use a typescript interface to maintain interoperability and better readability. See: src/SignedAccess.d.ts

It is recommended to end all pathnames with / unless you intentionally choose to end the pathname with a partial filename.
The pathname /data grants access to at least two of the following URLs:
example.com/database
example.com/data/file1

The signURL method needs to save the information in the searchParams, so the "expires, ip, method, nonce, prefix and signature" queries are reserved for this module's control. If your original url has one of these queries previously, it will be removed or overwritten to avoid conflicts in the signature verification.

The nonce is signed in the cookie or URL, but it's up to your application to save them and check if they've already been used.

Specifications

We strive to maintain complete code coverage in tests. With that, we provide all the necessary use cases for a good understanding of how this module works. See: test/SignedAccess.spec.js