Skip to content
This repository has been archived by the owner on Oct 14, 2022. It is now read-only.

Allows CORS on PSA Document? #118

Open
DougAnderson444 opened this issue Aug 15, 2019 · 17 comments
Open

Allows CORS on PSA Document? #118

DougAnderson444 opened this issue Aug 15, 2019 · 17 comments

Comments

@DougAnderson444
Copy link

DougAnderson444 commented Aug 15, 2019

@pfrazee I am trying to use beakerbrowser/dat-pinning-service-client to access hashbase.io/.well-known/psa from a non-beaker origin domain, but I am getting the error:

blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

I see #43 allowed CORS, but what about the PSA Document?

Has this issue already been addressed elsewhere or do we need a fix?

DougAnderson444 added a commit to DougAnderson444/hashfork that referenced this issue Aug 15, 2019
I ran into issue beakerbrowser#118 , here is a PR that I think will address the issue, for your consideration.
@DougAnderson444
Copy link
Author

Opened PR #119

@pfrazee
Copy link
Member

pfrazee commented Aug 15, 2019

Hmm... is there any possible reason we wouldn't want to allow this?

@DougAnderson444
Copy link
Author

Paul, Is that a trick question?
...I guess if you want to restrict programmatic pinning to hashbase to only beakerbrowser?

@pfrazee
Copy link
Member

pfrazee commented Aug 16, 2019

Eaaaasy man, I'm not trying to be a jerk. I couldn't remember off the top of my head whether CORS would send credentials from another origin or if there was any other security concern. You just dumped a PR on me and I think it's fair for me to ask.

AFAICT the answer is no. Existing credentials (cookies) are never sent if we set allow to *. That said, I'm not sure if you can get your own origin's cookies sent, which will be needed if you want to go through the pinning API's login session. Can you confirm that for me before we merge this?

@DougAnderson444
Copy link
Author

Ah, ok no worries I thought you might have wanted me to think deeper before asking for what I thought was needed. I'll look into the cookies and try to test it out first, it's just not my area of expertise.

If we need to pass cookies, from what I understand we may need to add:

res.header("Access-Control-Allow-Credentials", "true") // only if you want use client cookies

@pfrazee
Copy link
Member

pfrazee commented Aug 16, 2019

🍻 Appreciate it! If we have to set allow-credentials, we should make sure that doesn't allow credentials to get attached across origins.

@pfrazee
Copy link
Member

pfrazee commented Aug 16, 2019

If it turns out we can't get cookies to be sent without breaking session-isolation of SOP, we should look into sending the Authorization header instead of using cookies.

@DougAnderson444
Copy link
Author

DougAnderson444 commented Aug 16, 2019

See, I'm glad I asked then. I only got so far as trying to get the PSA Document, for which no credentials are required. I'm sure I would have hit this wall once the PSA doc was fetched and tried to log in. I'll continue to pick away at it.

@pfrazee
Copy link
Member

pfrazee commented Aug 16, 2019

For sure. I'm sorry my original response was short; tail end of the day.

@RangerMauve
Copy link

Anything I can do to help push this forward? 😁

@DougAnderson444
Copy link
Author

Oh yeah @RangerMauve ! Do you have a pinning server up?

I've been trying to bring one up to test this, but I've been running into challenges so far.

@RangerMauve
Copy link

A pinning server with the proper CORS headers? I can set one up for you tomorrow. 😁

I'll just expose my dat-store instance on Digital Ocean and see if that works.

@DougAnderson444
Copy link
Author

Oh, I thought if we were going to edit the hashbase code, we would need an instance of hashbase up and running?

Although, in looking at dat-store, that seems pretty straightforward. Is it really as easy as dat-share url?

@RangerMauve
Copy link

RangerMauve commented Aug 19, 2019

Oh, k. I'll see what I can do there. Hashbase requires a bunch more config, so that might take more time, but I think I can figure it out. 😁

dat-store should behave the same as an unauthenticated hashbase.

@RangerMauve
Copy link

Bleh. While getting the CORS stuff into dat store I got some sort of error with folder sync. 😭 Hopefully I'll have something this evening.

@RangerMauve
Copy link

of course it's a Windows problem. 😭

@RangerMauve
Copy link

K, lost most of my day to fixing some weird bugs in dat-store. I'll need to figure out setting up a CORS enabled store tomorrow instead. 😅

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants