RubyGems Navigation menu

rack-cors-csrf_prevention 0.2.0

The middleware makes sure any request to specified paths would have been preflighted if it was sent by a browser. We don't want random websites to be able to execute actual GraphQL operations from a user's browser unless our CORS policy supports it. It's not good enough just to ensure that the browser can't read the response from the operation; we also want to prevent CSRF, where the attacker can cause side effects with an operation or can measure the timing of a read operation. Our goal is to ensure that we don't run the context function or execute the GraphQL operation until the browser has evaluated the CORS policy, which means we want all operations to be pre-flighted. We can do that by only processing operations that have at least one header set that appears to be manually set by the JS code rather than by the browser automatically. POST requests generally have a content-type `application/json`, which is sufficient to trigger preflighting. So we take extra care with requests that specify no content-type or that specify one of the three non-preflighted content types. For those operations, we require one of a set of specific headers to be set. By ensuring that every operation either has a custom content-type or sets one of these headers, we know we won't execute operations at the request of origins who our CORS policy will block.

Gemfile:
= Copier Copié!

installation:
=

Versions:

  1. 0.2.1 - February 15, 2024 (8,5 ko)
  2. 0.2.0 - February 15, 2024 (8,5 ko)
  3. 0.1.0 - February 15, 2024 (8,5 ko)

Dépendances de Runtime (1):

rack >= 1

Dépendances de Development (3):

debug ~> 1.9, >= 1.9.1
rake ~> 13.0
rspec ~> 3.0

Propriétaires:

Pushed by:

Auteurs:

  • Digital Classifieds LLC

Total de contrôle SHA 256:

= Copier Copié!

Total de téléchargements 1 191

Pour cette version 205

Version publiée:

License:

MIT

Version de Ruby requise: >= 2.6.0

Liens: