AgregoreWeb / agregore-browser

A minimal browser for the distributed web (Desktop version)
https://www.youtube.com/watch?v=TnYKvOQB0ts&list=PL7sG5SCUNyeYx8wnfMOUpsh7rM_g0w_cu&index=14
GNU Affero General Public License v3.0
740 stars 66 forks source link

Fetch permissions #51

Open KyGost opened 3 years ago

KyGost commented 3 years ago

Unless if I'm mistaken, there is a lot of room for abuse with PUT and DELETE. We should make a permissions pop up eventually.

Perhaps approve permissions by URL, with temporary and permanent options?

RangerMauve commented 3 years ago

I think CORS would be a great place to start for this.

If a drive can set this header it can configure how it can be interacted with.

Beaker uses a .csp field in the index.json. Maybe we could take a similar approach? https://docs.beakerbrowser.com/developers/index.json-manifest#csp

RangerMauve commented 3 years ago

To enable that, we'd want to see if index.json exists, then fetch the csp field from it after parsing it as JSON and set that as the (Content-Securty-Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) header. https://github.com/RangerMauve/dat-fetch/blob/master/index.js#L110

RangerMauve commented 3 years ago

An extension could be useful here too.

Maybe the first time an origin tries to do a PUT or DELETE into a drive, the extension will prompt the user to allow it via a popup.

We could use window.open to create the window and window.postMessage to communicate the users's choice from it.

KyGost commented 3 years ago

After discussing me and @RangerMauve have decided: An extension that does:

If drive has negative perms in index.json:

Permission for a higher capacity also grants lower capacities

Perms are per drive + site pair

Perms stored in the extension's indexedDB

Need to use WebRequest API, changing fetch won't affect enough!

KyGost commented 3 years ago

Requests will occur at: https://github.com/AgregoreWeb/extension-agregore-permissions-fetch Agregore-side, we need:

RangerMauve commented 3 years ago

Mind elaborating a bit more on what negative permissions in index.json would look like? :o

KyGost commented 3 years ago

Seems you were thinking CSP. If not that, perhaps (GET is the only assumed positive permissions for now):

permissions: {
  GET: {
    'hyper://MYSITE'
  }
}

Not sure if the list would be sites that can access it or can't access it.

RangerMauve commented 3 years ago

Ah yeah, the CSP thing I was thinking of would be to implement the same function that Beaker has: https://docs.beakerbrowser.com/developers/index.json-manifest#csp

KyGost commented 3 years ago

That makes sense. Can it be used to prevent connections? Browsed over it quickly and it seemed to be specifying what it can connect to?

RangerMauve commented 3 years ago

Yeah, it can restrict domains from doing requests to the particular hyperdrive.

jolindroth commented 2 years ago

Hey, I think I could pick this issue up with some support. Could someone help break down the task into more manageable chunks?

RangerMauve commented 2 years ago

@jolindroth Thanks for offering to help!

One approach would be via a web extension extension that would do something like the following:

This should be a good first step to see how permissions could work and leaves room for more fine-grained permissions and fetching permission info from naifests within the site itself down the line.

Does that feel like something you'd be comfortable taking on? Is there more detail that you'd need to get started?

In the future it might be cool if we could dynamically change the CORS header on webistes with a permission prompt too. But that's probably a separate issue. 😁

jolindroth commented 2 years ago

Thanks, @RangerMauve. I'll give it a shot. Could I reach out to you on discord if I need to ask something?

RangerMauve commented 2 years ago

Thanks, @RangerMauve. I'll give it a shot. Could I reach out to you on discord if I need to ask something?

Yes! Feel free to chat about it on https://discord.gg/QMthd4Y or https://matrix.to/#/#agregore:mauve.moe I'm usually most active on weekdays and sometimes Sundays. 😁

RangerMauve commented 1 year ago

An additional bit would be the ability to bypass CORS for general sites.

Here's how one could go about doing this:

Pantyhose-X commented 1 year ago

Thanks, @RangerMauve. I'll give it a shot. Could I reach out to you on discord if I need to ask something?

Yes! Feel free to chat about it on https://discord.gg/QMthd4Y or https://matrix.to/#/#agregore:mauve.moe I'm usually most active on weekdays and sometimes Sundays. 😁

Add Contact to https://rvlt.gg/