inrupt / inrupt/solid-client-authn-js

Unable to pass custom Headers

Open
#1,708 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
77
Forks
49
Avg merge
18h 20m
Merged PRs (30d)
32

Description

Search terms you've used

headers, fetch init

Impacted package

Which packages do you think might be impacted by the bug ?

  • solid-client-authn-browser
  • solid-client-authn-node
  • solid-client-authn-core
  • oidc-client-ext
  • Other (please specify): ...
Bug description

This library seems assume that the headers field within the init object of a fetch always uses the Record<string, string> form, while this can also be a string[][] or Headers.

Within Comunica, we're consistently passing around Headers objects. But when it reaches this auth library, the headers become mangled, which causes several issues (such as being unable to set the content type on PUT/PATCH requests).

Related to #176, #96

To Reproduce

session.fetch('...', { headers: new Headers({ 'Content-Type': 'text/turtle' }) })

Expected result

Headers are delegated properly

Actual result

Headers are ignored

Environment

Please run

npx envinfo --system --npmPackages --binaries --npmGlobalPackages --browsers

in your project folder and paste the output here:


  System:
    OS: macOS 10.15.4
    CPU: (8) x64 Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz
    Memory: 23.36 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 16.2.0 - /usr/local/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 7.13.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 94.0.4606.61
    Firefox: 91.0.2
    Safari: 13.1
  npmGlobalPackages:
    @comunica/actor-init-sparql-file: 1.14.0
    @ldflex/comunica: 3.4.2
    chrome-headless-render-pdf: 1.9.0
    clinic: 8.0.1
    componentsjs-generator: 2.6.0
    generator-comunica: 1.0.0
    http-server: 0.12.3
    ldbc-snb-enhancer: 1.0.2
    n: 6.5.1
    npm-cli-adduser: 1.1.4
    npm: 7.13.0
    rdf-dataset-fragmenter: 1.2.0
    rdf-dereference: 1.5.0
    renovate: 23.20.2
    verdaccio: 3.11.4
    why-is-node-running: 2.2.0
    yo: 3.1.1

Additional information

Places like here may need another way of merging Headers instead of using destructuring.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in packages/core/src/authenticatedFetch/fetchFactory.ts around the referenced header-merging code. Reproduce the issue with session.fetch and a Headers object containing Content-Type, then inspect how the fetch init is passed through. Done means Headers objects are delegated correctly and the reported PUT/PATCH content-type behavior no longer occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
authentication
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.