graphprotocol / graph-tooling

Monorepo for various tools used by subgraph developers.
https://thegraph.com/docs
Apache License 2.0
386 stars 206 forks source link

fix: basic auth #927

Closed islishude closed 2 years ago

islishude commented 2 years ago

There is no auth field in URL.

new URL('https://:password@example.com/path');
URL {
  href: 'https://:password@example.com/path',
  origin: 'https://example.com',
  protocol: 'https:',
  username: '',
  password: 'password',
  host: 'example.com',
  hostname: 'example.com',
  port: '',
  pathname: '/path',
  search: '',
  searchParams: URLSearchParams {},
  hash: ''
}
air3ijai commented 2 years ago

@islishude, does this code fix basic auth for IPFS endpoint as well?

I did some tests and got the following results

Graph build - :x:

yarn graph build subgraph.yaml --ipfs https://user:pass@ipfs.domain.tld

✖ Failed to upload subgraph to IPFS: Failed to upload file to IPFS: Server responded with 404

This is reply from IPFS node and it means that same credentials works correctly with curl

curl https://user:pass@ipfs.domain.tld

404 page not found

Graph create - :white_check_mark:

yarn graph create subgraph.yaml --node https://user:pass@rinkeby.index.domain.tld

Created subgraph: subgraph-test

Graph deploy - :x:

yarn graph deploy subgraph-test subgraph.yaml \
  --version-label subgraph-test \
  --ipfs https://user:pass@ipfs.domain.tld \
  --node https://user:pass@rinkeby.index.domain.tld

✖ Failed to upload subgraph to IPFS: Failed to upload file to IPFS: Server responded with 404

Does your code fix basic authentication for IPFS node?

islishude commented 2 years ago

No, it's used for jsonrpc

you can also make a PR for ipfs

https://github.com/graphprotocol/graph-cli/blob/main/src/command-helpers/compiler.js#L22-L29